Dim adoCnn As New ADODB.Connection Dim adoCmm As New ADODB.Command Dim adoRec As New ADODB.Recordset adoCnn.CursorLocation = adUseClient adoCnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB;Persist Security Info=False" adoCmm.ActiveConnection = adoCnn adoCmm.CommandType = adCmdText adoCmm.CommandText = "select * from employees" Set adoRec = adoCmm.Execute
Set DataGrid1.DataSource = adoRec
我个人认为还是这样比较好:工程--->引用--->Microsoft ActiveX Data Object 2.x(版本号) Dim CN As New ADODB.Connection '定义数据库的连接 Dim Rs As New ADODB.Recordset CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\NWIND.MDB;Persist Security Info=False" CN.Open Rs.CursorLocation = adUseClient Rs.Open "select * from employees", CN, adOpenDynamic, adLockBatchOptimistic
如:set rs=conn.execute("select * from company")
或 rs.open "select * from company",conn
rsTemp.Open "Select * From table " strCnn , adOpenDynamic, adLockPessimistic
Dim adoCnn As New ADODB.Connection
Dim adoCmm As New ADODB.Command
Dim adoRec As New ADODB.Recordset adoCnn.CursorLocation = adUseClient
adoCnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB;Persist Security Info=False" adoCmm.ActiveConnection = adoCnn
adoCmm.CommandType = adCmdText
adoCmm.CommandText = "select * from employees"
Set adoRec = adoCmm.Execute
Set DataGrid1.DataSource = adoRec
Dim Rs As New ADODB.Recordset CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\NWIND.MDB;Persist Security Info=False"
CN.Open Rs.CursorLocation = adUseClient
Rs.Open "select * from employees", CN, adOpenDynamic, adLockBatchOptimistic
if rs!age>12 then
.........
end if
wend
for IndexAge =rs.RecordCount
if rs!age>12 then
'输出数据
end if
next