'定义ADO的Connection对象 Dim cn As New ADODB.Connection '定义ADO的Recordset对象 Dim rst As ADODB.Recordset '创建SQL Server连接 cn.Open "Provider=SQLOLEDB.1;Remote Server=127.0.0.1", "rzzx", "bjjhzjqs" '执行查询语句 Set rst = cn.Execute("SELECT CompanyName FROM Northwind.dbo.Customers where ContactTitle = 'Sales Agent'")
Dim cn As New ADODB.Connection
'定义ADO的Recordset对象
Dim rst As ADODB.Recordset
'创建SQL Server连接
cn.Open "Provider=SQLOLEDB.1;Remote Server=127.0.0.1", "rzzx", "bjjhzjqs"
'执行查询语句
Set rst = cn.Execute("SELECT CompanyName FROM Northwind.dbo.Customers where ContactTitle = 'Sales Agent'")
strDBName="Test"
connSql.ConnectionString = "driver={SQL Server};server=" & strServer & ";Password=" _
& pass & ";Persist Security Info=True;User ID=" & user & ";DATABASE=" & strDBName