Dim Cnn,Rst,strCnn
Set Cnn = CreateObject ( "ADODB.Connection" )
Set Rst = CreateObject ( "ADODB.Recordset")
strCnn = "Provider=SQLOLEDB; User ID=sa;Password=1qaz!QAZ; Data Source=LUZHOU\blue;Initial Catalog=TSQLFundamentals2008"
Cnn.Open strCnn
Rst.Open "Select * from Sales.Customers",Cnn
Rst.MoveFirst
Do While Not Rst.EOF
MsgBox Trim(Rst.Fields("contactname"))
Rst.MoveNext
Loop
Rst.Close
Cnn.Close
The string consists of a few parts:
Provider: the type of connection you are establishing, in this case SQL Server.
Data Source: The server you are connecting to.
Initial Catalog: The name of the database.
user id: your username.
password: um, your password. ;)
VBS 连接 ODBC
最新推荐文章于 2024-04-21 13:40:11 发布