我给你一个例子:
我的数据库在桌面上:名叫test
Public cnn As New ADODB.Connection
'这建立一个连接。
Private Sub Command1_Click()
Dim rst As New ADODB.Recordset
Dim sql As String
sql = "select * from test where ID='1'"
rst.CursorLocation = adUseClient
rst.Open sql, cnn, adOpenStatic, adLockReadOnly
Me.Text1.Text = rst.Fields("ID").Value
Me.Text2.Text = rst.Fields("test2").Value
Set Me.DataGrid1.DataSource = rst
End Sub
Private Sub Form_Load()
Dim Connectionstring As String
Connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\桌面\test.mdb;Persist Security Info=False"
cnn.Open Connectionstring
End Sub
提取到什么地方?
要提取的地方=data1.recordset.fields("字段名")
用data.fileds("字段")