窗体上放:adodc1,adodc2,option1,option2,DataGrid1.代码如下:
Private Sub Option1_Click()
With Adodc1
.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & App.Path & "\\fld.mdb;Persist Security Info=False"
.CommandType = adCmdText
.RecordSource = "select * from table1"
.Refresh
End With
Set DataGrid1.DataSource = Adodc1
End Sub
Private Sub Option2_Click()
With Adodc2
.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & App.Path & "\\fld.mdb;Persist Security Info=False"
.CommandType = adCmdText
.RecordSource = "select * from table2"
.Refresh
End With
Set DataGrid1.DataSource = Adodc2
End Sub
试过了,没问题.