B
bnlywj
Unregistered / Unconfirmed
GUEST, unregistred user!
我现在写的东西里面有两个这样的连接,一个连接原始数据库,一个连接目标数据库,当初只有一个连接的时候DBGrid是显示内容的,但增加了一个连接后就不显示了,是什么原因啊 代码如下: procedure TForm1.Button1Click(Sender: TObject);// 连接原始数据库 var str1: string; begin if OpenDialog1.Execute then Edit1.Text:=OpenDialog1.FileName; str1:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+edit1.text+';Persist Security Info=False'; ADOConnection1.Close; ADOConnection1.ConnectionString:=str1; ADOConnection1.Open; ADOConnection1.GetTableNames(ComboBox1.Items); end; procedure TForm1.ComBoBox1Change(Sender:TObject); begin ADOTable1.Close; ADOTable1.Connection:=ADOConnection1; ADOTable1.TableName:=ComboBox1.text; ADOTable1.active:=true; DataSource1.DataSet:=ADOTable1; DBGrid1.DataSource:=DataSource1; end; procedure TForm1.Button2Click(Sender: TObject);// 连接目标数据库 var str2: string; begin if Opendialog2.Execute then Edit2.Text:=OpenDialog2.FileName; str2:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+edit2.text+';Persist Security Info=False'; ADOConnection2.Close; ADOConnection2.ConnectionString:=str2; ADOConnection2.Open(); ADOConnection2.GetTableNames(ComboBox2.Items); end; procedure TForm1.ComBoBox2Change(Sender:TObject); begin ADOTable2.Close; ADOTable2.Connection:=ADOConnection2; ADOTable2.TableName:=ComboBox2.text; ADOTable2.active:=true; DataSource2.DataSet:=ADOTable2; DBGrid2.DataSource:=DataSource2; end;