工程--->引用--->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 DataGrid1.DataSource = Rs
在菜单"工程/引用/Microsoft ActiveX Data Object 2.x(版本号)" Dim CN As New ADODB.Connection Dim Rs As New ADODB.Recordset cn.ConnectionString = "DBQ=" & App.Path & "\TelePhone.mdb;DefaultDir=" & _ App.Path & ";Driver={Microsoft Access Driver (*.mdb)};UID=ADMIN;PWD=admind1234;" cn.Open
dim N as long Dim strSQL As String
dim conn as New ADODB.Connection dim rs as New ADODB.Recordset
With conn If .State = adStateOpen Then .Close End If .CursorLocation = adUseClient .ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & strSQL .Open End With
With rs .Open "Select * from Authors;", conn, adOpenStatic, adLockOptimistic If .BOF And .EOF Then msgbox "没有任何记录" Exit Sub End If .MoveFirst .movelast msgbox "有" & .recordcount & "条记录!" N = .recordcount End With
dim conn as ADODB.Connection dim rs as ADODB.Recordset set conn = new adodb.connection conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DataBasePath\DATABASEName.mdb;Persist Security Info=False" set rs=new adodb.recordset rs.open "Select * from 表名",conn,adOpenDynamic,adLockOptimistic
dim N as long Dim strSQL As String
dim conn as New ADODB.Connection dim rs as New ADODB.Recordset
With conn If .State = adStateOpen Then .Close End If .CursorLocation = adUseClient .ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & strSQL .Open End With
With rs .Open "Select * from Authors;", conn, adOpenStatic, adLockOptimistic If .BOF And .EOF Then msgbox "没有任何记录" Exit Sub End If .MoveFirst .movelast msgbox "有" & .recordcount & "条记录!" N = .recordcount End With
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 DataGrid1.DataSource = Rs
Dim Rs As New ADODB.Recordset
cn.ConnectionString = "DBQ=" & App.Path & "\TelePhone.mdb;DefaultDir=" & _
App.Path & ";Driver={Microsoft Access Driver (*.mdb)};UID=ADMIN;PWD=admind1234;"
cn.Open
Dim strSQL As String
dim conn as New ADODB.Connection
dim rs as New ADODB.Recordset
strSQL = App.Path & "\Biblio.mdb"
strSQL = Replace(strSQL, "\\", "\")
With conn
If .State = adStateOpen Then
.Close
End If
.CursorLocation = adUseClient
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & strSQL
.Open
End With
With rs
.Open "Select * from Authors;", conn, adOpenStatic, adLockOptimistic
If .BOF And .EOF Then
msgbox "没有任何记录"
Exit Sub
End If
.MoveFirst
.movelast
msgbox "有" & .recordcount & "条记录!"
N = .recordcount
End With
dim rs as ADODB.Recordset
set conn = new adodb.connection
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DataBasePath\DATABASEName.mdb;Persist Security Info=False"
set rs=new adodb.recordset
rs.open "Select * from 表名",conn,adOpenDynamic,adLockOptimistic
Dim strSQL As String
dim conn as New ADODB.Connection
dim rs as New ADODB.Recordset
strSQL = App.Path & "\Biblio.mdb"
strSQL = Replace(strSQL, "\\", "\")
With conn
If .State = adStateOpen Then
.Close
End If
.CursorLocation = adUseClient
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & strSQL
.Open
End With
With rs
.Open "Select * from Authors;", conn, adOpenStatic, adLockOptimistic
If .BOF And .EOF Then
msgbox "没有任何记录"
Exit Sub
End If
.MoveFirst
.movelast
msgbox "有" & .recordcount & "条记录!"
N = .recordcount
End With