0

有人可以帮我解释一下为什么这段代码在 ExecSQL 语句上崩溃了吗?

function UpdateLastBankResponsesId(ADatabase: TDatabase; AValue: Integer): String;  
var  
AQuery2: TQuery;  
begin 
result:= ''; 
AQuery2:= TQuery.Create(nil); 
AQuery2.DatabaseName:= ADatabase.DatabaseName;  
with AQuery2 do  
begin  
SQL.Text:= 'UPDATE last_id Set TABLENAME =:ATableName, LASTID=:ALastId';  
ParamByName('ATableName').AsString:= 'responses';  
ParamByName('ALastId').AsInteger:= AValue;  
try  
ExecSql; //***** CRASHES HERE *****  
except  
begin  
ExitCode:= 16;  
raise ECustomException.create('Error Updating Last Id table!');  
end;//except  
end; //try  
end; //with  
AQuery2.Free;  
end;  
4

1 回答 1

0

我试图设置一个已经存在的值

Set TABLENAME =:ATableName  

我实际上只需要设置 LASTID

UPDATE last_id SET LASTID=:ALastId WHERE TABLENAME =:ATableName  

我不敢相信我做到了

于 2011-02-08T14:44:35.050 回答