sql与edit中的加减问题!没有错误了,可是库没更新!:)(10分)

Y

yyjqtww

Unregistered / Unconfirmed
GUEST, unregistred user!
var
Form16: TForm16;
str:string;
str1:string;
total:integer;
......
query2.Close;
query2.SQL.Clear;
str:='select isbn from ykucuntab where isbn='+''''+edit2.Text+''''+'';
query2.sql.add(str);
query2.Open;
if query2.RecordCount<>0 then
try
with Query2 do
begin
Close;
total:=total+strtoint(edit8.text);
SQL.Text:='update ykucuntab set total=total where isbn='+''''+edit2.text+''''+'';
ExecSQL;
end;
except
raise
end
怎么办呢?不好意思啊,老是麻烦各位!
 
>>SQL.Text:='update ykucuntab set total=total where isbn='+
''''+edit2.text+''''+'';
'total=total'//老兄,你这使什么意思,SQL会把后面那个Total当成字符
串来处理,你的想法后面的total应该用total+strtoint(edit8.text)来替换,
当然这一句Sql不符合你的意思,因此执行时找不到符合条件的记录,自然执行
不成功,正确表达英如下:
SQL.Text:='update ykucuntab set total='+
IntToStr(total)+
' where isbn='+
''''+edit2.text+''''+'';
 
接受答案了.
 
顶部