这种情况下的update语句为何总是出错?(30分)

F

f_5110

Unregistered / Unconfirmed
GUEST, unregistred user!
数据库连接用ADO,ACCESS。
用临时库b中editfieldname:)string)更新库a中的同一个字段,总提示b.字段名没有默认值。
adoquery1.sql.add('update a set a.'+editfieldname+'=b.'+editfieldname+' where c=b.c');
adoquery1.execsql;
 
update a,b
set a.fieldname=b.fieldname
werh a.c=b.c

改为下面试试
adoquery1.sql.add('update a,b set a.'+editfieldname+'=b.'+editfieldname+' where a.c=b.c');
 
to quicksilver:语法错误,操作符丢失!
 
adoquery1.sql.add('update a set a.'+editfieldname+'=b.'+editfieldname+' where a.c=b.c');
就这样不行么?
 
'update a set a.'+editfieldname+'=b.'+editfieldname+' from a,b where a.c=b.c'
 
b.字段名没有默认值???
 
能否提供一个完整的例程发到我信箱f_5110@sina.com,要能在D6+ACCESS2000下通过。
马上送分
 
没人知道为什么吗?送分也不要了吗?
 
SQL.ADD(Format('update a set a.%s=b.%s from a,b where a.c=b.c',[editfieldname,editfieldname]));
ExecSQL;
 
你这只是书写的问题,不过我还是要谢谢,顺便告诉一下:故障依然
 
update a set your_field=(select your_field from b where a.c=b.c)
 
补充:一些数据库如oracle是有效的,access则不知道
还有 select your_field from b where a.c=b.c 必须是返回一行的
 
难道ACCESS数据库对二表更新的SQL语句不支持???不可能吧
 
var
s:string;
begin
s:='update a set a.'+editfieldname+'=b.'+editfieldname+' where a.c=b.c';
.
.
adoquery1.sql.add(s);
execsql;
end;
 
我最初的代码也是这样啊,可就是出错!提示b.字段名没有默认值
 
跟踪一下,看一下
'update a set a.'+editfieldname+'=b.'+editfieldname+' where a.c=b.c';
语句在参数赋值后是如何的,这样你应该就能发现问题了。
 
赋值结果是:'update a set a.a02=b.a02 where a.a01=b.a01'
我感觉问题可能不是出在sql语句上,那么又有可能出在什么地方呢?
这两个表也都存在,相应的字段也有。???????help me!!
 
给b.a2这个字段加一个默认值试试,或者让a表的a2字段允许为空值
 
b.a02都有值,允不允许为空我也试过了,没效果!
再加30分希望富翁们帮我实际测试一下
 
难道ACCESS数据库对二表更新的SQL语句不支持???不可能吧
 
顶部