Dim strSQL As String Dim cnn As New ADODB.Connection Dim rst As New ADODB.Recordset Dim strTemp As String strTemp = App.Path & "\shlr.mdb" cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & strTemp & ";Jet OLEDB:Database Password=" cnn.Open
strSQL = "select * from ttt where month(dt)=4 and day(dt)=5 " strSQL = "select * from sysobjects" rst.Open strSQL, cnn, adOpenDynamic, adLockOptimistic while not rst.eof ......... rst.movenext wend If rst.State = 1 Then rst.Close Set cnn = Nothing Set rst = Nothing
Set rs = conn.Execute(strsql)
'Set rs = NothingDim strkey As String
rs.Open "select id from lb where mc='" & Trim(Txtlb) & "'", conn
rs.open sql,cnn,adOpenDynamic
cnn为活动连接
adOpenDynamic为打开方式
Dim adoCmm As New adodb.Command
Dim adoRec As New adodb.Recordset
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
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strTemp As String
strTemp = App.Path & "\shlr.mdb"
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & strTemp & ";Jet OLEDB:Database Password="
cnn.Open
strSQL = "select * from ttt where month(dt)=4 and day(dt)=5 "
strSQL = "select * from sysobjects"
rst.Open strSQL, cnn, adOpenDynamic, adLockOptimistic
while not rst.eof
.........
rst.movenext
wend
If rst.State = 1 Then rst.Close
Set cnn = Nothing
Set rst = Nothing