你想要没有的比较麻烦,我只知道如何做子母表,给你个思路
先加一个adoquery1连接到数据库a的表1,
adoquery1.sql:='select name from table1';
并加一个数据源
datasource1.dateset:=adoquery1;
再加一个adoquery2连接到数据库b的表2
adoquery2.datasource:=datasource1;
adoquery2.sql:='select * from employee
where deptid=:name';
注意:name是adoquery1.fieldbyname('name')的值,所以一次就一个值。
这样的异构查询没问题,但是你要的是not in query1,我也没什么办法
只好复制到一个数据库中再select了
with ADOQuery1 do
begin
SQL.Clear;
SQL.Add('select * from 场地.场地表 where 场地代码 not in (select 场地名 from ReportMake.场地表)');
ExecSQL;
first;
while not ADOQuery1.Eof do
begin
StringGrid1.Cells[0,row_num]:=cddaima;
StringGrid1.Cells[1,row_num]:='今天没有报帐';
row_num:=row_num+1;
StringGrid1.RowCount:=StringGrid1.RowCount+1;
next;
end;
end;
结果是执行时报错:ADOQuery1:Cannot perform this operation on a closed dataset