WEB开发网
开发学院数据库MSSQL Server sql server动态连接odbc的dsn 阅读

sql server动态连接odbc的dsn

 2007-11-11 10:53:18 来源:WEB开发网   
核心提示: Dim cn As rdoConnection Dim ps As rdoPreparedStatement Dim rs As rdoResultset Dim strConnect As String Dim strSQL As String '利用 DSNless 连接到 pubs 数据库 '改

  Dim cn As rdoConnection

Dim ps As rdoPreparedStatement

Dim rs As rdoResultset

Dim strConnect As String

Dim strSQL As String

'利用 DSNless 连接到 pubs 数据库

'改变参数以适合你自己的 sql server(WINDOWS平台上强大的数据库平台)

strConnect = "Driver={sql server(WINDOWS平台上强大的数据库平台)}; Server=myserver; " & "Database=pubs; Uid=sa; Pwd="

Set cn = rdoEnvironments(0).OpenConnection(dsName:="", Prompt:=rdDriverNoPrompt, ReadOnly:=False, Connect:=strConnect)

strSQL = "Select so.name,sc.name,st.name,sc.length " & "FROM syscolumns sc,master..systypes st,sysobjects so " & "WHERE sc.id in (select id from sysobjects where type ='P')" & " AND so.type ='P' " & "AND sc.id = so.id " & "AND sc.type = st.type " & "AND sc.type <> 39"

Set ps = cn.CreatePreparedStatement("MyPs", strSQL)

Set rs = ps.OpenResultset(rdOpenStatic)

list1.AddItem "SP Name,Param Name,Data Type,Length"

While Not rs.EOF

list1.AddItem rs(0) & " , " & rs(1) & " , " & rs(2) & " , " & rs(3)

rs.MoveNext

Wend

rs.Close

Set rs = Nothing

cn.Close

Set cn = Nothing

上一页  1 2 3 4 5 6 7 8  下一页

Tags:sql server 动态

编辑录入:coldstar [复制链接] [打 印]
赞助商链接