Dim g_Conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
m_strConn = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & App.Path & "D:\project\AotuCar\db\conf.mdb;uid=" & ";pwd=;"
g_Conn.Open m_strConn
Set cmd.ActiveConnection = g_Conn
With g_Conn
If .State = adStateOpen Then .Close
.ConnectionString = m_strConn
.CursorLocation = adUseClient
.ConnectionTimeout = 10000
.CommandTimeout = 10000
.CursorLocation = adUseClient
.Open
End With
If rs.State = adStateOpen Then rs.Close
strSql = "select * from Tbuser"
rs.Open strSql, g_Conn, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rs
strConn = "Provider=SQLOLEDB;Data Source=MIN;" & _
"Initial Catalog=Northwind;" & _
"User ID=sa;Password=1234;"
strSQL = "SELECT CustomerID, CompanyName FROM Customers"
Dim cnNorthwind As New ADODB.Connection
cnNorthwind.Open strConn
Dim rsCustomers As New ADODB.Recordset
With rsCustomers
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
End With
Set rsCustomers = cnNorthwind.Execute(strSQL)
Set DataGrid1.DataSource = rsCustomers