access数据库内,用一个表内容更新另一个表,access内可以正确执行!但在delphi内无法执行,整整一天,找不出问题出在那了?那位大神帮看看!
sql:='';
for i:=0 to 2 do
begin
case i of
0: sql:='update dfk,temp set dfk.yw=temp.yw where (dfk.id=temp.id) and (dfk.yw is null or dfk.yw=0) and (temp.yw>0)';
1: sql:='update dfk,temp set dfk.sx=temp.sx where (dfk.id=temp.id) and (dfk.sx is null or dfk.sx=0) and (temp.sx>0)';
2: sql:='update dfk,temp set dfk.wy=temp.wy where (dfk.id=temp.id) and (dfk.wy is null or dfk.wy=0) and (temp.wy>0)';
end;
adoquery1.close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(sql);
ADOQuery1.ExecSQL;
aa:=adoquery1.RowsAffected;
end;
两个表,一个dfk,一个temp,表结构完全相同,通过ID对应关系,如果dfk表中yw,sx,wy三个字段值为0或空而temp表中yw,sx,wy三个字段值大于0,即用temp表的值更新dfk表的相应字段的值!急啊!
sql:='';
for i:=0 to 2 do
begin
case i of
0: sql:='update dfk,temp set dfk.yw=temp.yw where (dfk.id=temp.id) and (dfk.yw is null or dfk.yw=0) and (temp.yw>0)';
1: sql:='update dfk,temp set dfk.sx=temp.sx where (dfk.id=temp.id) and (dfk.sx is null or dfk.sx=0) and (temp.sx>0)';
2: sql:='update dfk,temp set dfk.wy=temp.wy where (dfk.id=temp.id) and (dfk.wy is null or dfk.wy=0) and (temp.wy>0)';
end;
adoquery1.close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(sql);
ADOQuery1.ExecSQL;
aa:=adoquery1.RowsAffected;
end;
两个表,一个dfk,一个temp,表结构完全相同,通过ID对应关系,如果dfk表中yw,sx,wy三个字段值为0或空而temp表中yw,sx,wy三个字段值大于0,即用temp表的值更新dfk表的相应字段的值!急啊!
解决方案 »
- 如何定义超长数字类型字符串的自增函数
- button的风格怎么没了?
- 可以使用任何字体的gvim for win32
- dbgrideh 的一个小问题,超难很有用(自动计算) 我想这个问题很有用?对大家也有很帮助
- 很简单的问题实在搞不明白
- 如何让ListView里面的行高增加?
- dbgrib中记录显示问题---在线
- 200分提问!!!----DELPHI程序调试求救
- 我的机器是winXP,开发工具delphi7.0,office装的2003,死活不能调用excel。
- 一个不错的程序: http://www.playicq.com/dispsoft.php?id=365
- 求各位大侠,这段代码是什么意思?
- 改变Form标题栏的颜色,不想它是蓝色,太死板,送40分
但在ACCESS内可以正确执行,并有更新记录数!
sql:='';
for i:=0 to 2 do
begin
case i of
0: sql:='update dfk set dfk.yw=temp.yw from temp where (dfk.id=temp.id) and (dfk.yw is null or dfk.yw=0) and (temp.yw>0)';
1: sql:='update dfk set dfk.sx=temp.sx from temp where (dfk.id=temp.id) and (dfk.sx is null or dfk.sx=0) and (temp.sx>0)';
2: sql:='update dfk set dfk.wy=temp.wy from temp where (dfk.id=temp.id) and (dfk.wy is null or dfk.wy=0) and (temp.wy>0)';
end;
adoquery1.close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(sql);
ADOQuery1.ExecSQL;
aa:=adoquery1.RowsAffected;
end;
sql:='';
for i:=0 to 2 do
begin
case i of
0: sql:='update dfk,temp set dfk.yw=temp.yw where (dfk.id=temp.id) and (dfk.yw is null or dfk.yw=0) and (temp.yw>0)';
1: sql:='update dfk,temp set dfk.sx=temp.sx where (dfk.id=temp.id) and (dfk.sx is null or dfk.sx=0) and (temp.sx>0)';
2: sql:='update dfk,temp set dfk.wy=temp.wy where (dfk.id=temp.id) and (dfk.wy is null or dfk.wy=0) and (temp.wy>0)';
end;
adoquery1.close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(sql);
ADOQuery1.ExecSQL;
aa:=adoquery1.RowsAffected;
end;
语法错误(操作符丢失)在查询表达式'temp.yw from temp'中
ACCESS的update没有from子句吧!郁闷啊!
我在sql查询分析器中跑了下你的sql语句,好像是你的查询语句有问题!因为access用的语言和SQl 好像有点儿区别的!你设个断点儿跑一跑吧!
要不你换种写法“update dfk set dfk.yw=( select temp.yw from temp , dfk where (dfk.id=temp.id) and (dfk.yw is null or dfk.yw=0) and (temp.yw>0) )
”