adoquery3查询数据循环安插adoquery1里面
adoquery3查询数据循环插入adoquery1里面
adoquery1总共有6个字段'a','b','c','d','e','f',adoquery3先用select h from table,有字段h,怎么把adoquery3查询的数据插入adoquery1的a里面啊,然后b,c,d,e,f字段都为0!求教,谢谢啊
------最佳解决方案--------------------
var
h: string;
begin
with adoquery3 do
begin
close;
sql.clear;
sql.add('select h from table');
open;
while not eof do
begin
h := FieldByName('h').AsString;
with adoquery1 do
begin
close;
sql.clear;
sql.add('insert into table2(a,b,c,d,e,f) values ('''
+ h ''', 0,0,0,0,0)');
ExecSql;
end;
Next;
end;
end;
end;
------其他解决方案--------------------
你跟踪程序是在执行插入的时候报错吗?如果是看一下数据库字段的类型之类,大小,是否为空等项。
还有就是with这个东西少用,尤其是这种嵌套使用,很有可能出错,你最好是把这个去掉试试!
------其他解决方案--------------------
运行的时候显示不正常的定义参数对象,提供了不一致或者不完整的信息!将将adoquery 的 ParamCheck设置为 false后还有问题,怎么回事呢。
------其他解决方案--------------------
sql.add('insert into table2(a,b,c,d,e,f) values ('''
+ h + ''', 0,0,0,0,0)');
------其他解决方案--------------------
这个我知道的,我已经添加了,之前我自己也试过,就是插入的时候出现‘不正常的定义参数对象,提供了不一致或者不完整的信息’将adoquery 的 ParamCheck设置为 false后提示不是可以识别的 OPTIMIZER LOCK HINTS 选项
------其他解决方案--------------------
adoquery1总共有6个字段'a','b','c','d','e','f',adoquery3先用select h from table,有字段h,怎么把adoquery3查询的数据插入adoquery1的a里面啊,然后b,c,d,e,f字段都为0!求教,谢谢啊
------最佳解决方案--------------------
var
h: string;
begin
with adoquery3 do
begin
close;
sql.clear;
sql.add('select h from table');
open;
while not eof do
begin
h := FieldByName('h').AsString;
with adoquery1 do
begin
close;
sql.clear;
sql.add('insert into table2(a,b,c,d,e,f) values ('''
+ h ''', 0,0,0,0,0)');
ExecSql;
end;
Next;
end;
end;
end;
------其他解决方案--------------------
你跟踪程序是在执行插入的时候报错吗?如果是看一下数据库字段的类型之类,大小,是否为空等项。
还有就是with这个东西少用,尤其是这种嵌套使用,很有可能出错,你最好是把这个去掉试试!
------其他解决方案--------------------
运行的时候显示不正常的定义参数对象,提供了不一致或者不完整的信息!将将adoquery 的 ParamCheck设置为 false后还有问题,怎么回事呢。
------其他解决方案--------------------
sql.add('insert into table2(a,b,c,d,e,f) values ('''
+ h + ''', 0,0,0,0,0)');
------其他解决方案--------------------
这个我知道的,我已经添加了,之前我自己也试过,就是插入的时候出现‘不正常的定义参数对象,提供了不一致或者不完整的信息’将adoquery 的 ParamCheck设置为 false后提示不是可以识别的 OPTIMIZER LOCK HINTS 选项
------其他解决方案--------------------
begin
with adoquery3 do
begin
close;
sql.clear;
adoquery3.SQL.Text:='select distinct '
+'n.remote_id from user_data as m inner join readdata as n on m.'
+'remote_id=n.remote_id and m.selinfo='''+h+''''
+' where m.remote_id not in(select e.remote_id from readdata as e inner join'
+'(select distinct a.xiaoqu_name ,a.remote_id as remote_id,max(b.readtime)'