Private Sub form_load()
Dim adoRecordset As ADODB.Recordset
Set adoRecordset = New ADODB.Recordset
Dim i As Integer
Dim j As Integer
For i = 1 To 你的datagrid准备显示的列数
adoRecordset.Fields.Append "第" & i & "列", adVariant
Next i
adoRecordset.Open
For j = 1 To 你的datagrid准备显示的列数
adoRecordset.AddNew
Next j
Set DataGrid1.DataSource = adoRecordset
adoRecordset.MoveFirst
Adodc1.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=" _
& App.Path & "\dvdlent.mdb;Mode=ReadWrite;Persist Security Info=True;Jet OLEDB:Database Password=vcdglxt"
Adodc1.CursorLocation = adUseClient
Adodc1.CommandType = adCmdText
你要按得那个按钮的代码:
Private Sub Command1_Click()
SQL = "select * from dingdan"
Adodc1.RecordSource = SQL
Set DataGrid1.DataSource = Adodc1
Adodc1.Refresh
OpenDBFile
gCon.Execute SQL
CloseDBFile
End Sub
我也是才学会vb,郁闷了好长时间才弄出来,希望对你有用!