一个窗体,3个datagrid,共计3个表,一个表对应一个datagrid,点击datagrid1(打开该窗体时已经被赋值),根据datagrid1中的某个值,查询表2和表3,并把符合条件的分别赋值给datagrid2和datagrid3,要怎么写 VB code: Private Sub DataGrid1_Click() '在此处写SQL查询语句获得记录集,并绑定该记录集到另外的DataGrid控件 End Sub
我知道这样写,可是查询语句和连接数据库经常错误,不知道那里错了 VB code: Private Sub DataGrid1_Click() DataGrid2.Visible = False Adodc2.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=jwl_dbf" Adodc2.RecordSource = "select * from JWCK_BM" & " where 备件代码 ='" & Adodc1.Recordset(2) & "'" Adodc2.Refresh Text1.SetFocus DataGrid2.Visible = True End Sub