'工程-引用,Microsoft ADO
Dim StrCon1 As String
Dim Con1 As New ADODB.Connection
Dim Rst1 As New ADODB.Recordset
Dim tkSQL As String
StrCon1 = "Provider=Microsoft.JET.OLEDB.4.0;Data Source='" & "D:\Temp.mdb" & "'"
'连接字符串,指向您的数据库文件
Con1.ConnectionString = StrCon1
Con1.Open
'连接到数据库
tkSQL = "SELECT * FROM Test"
'查询语句
Rst1.Open tkSQL, Con1, adOpenDynamic, adLockOptimistic
'打开表
Me.Text1.Text = Rst1("Field1")
'读取当前记录中的Field1字段