参数化查询帮助(使用 Delphi 7 和 BDE)
有人可以帮助我并向我解释为什么此代码在 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;
Can someone help me and explain to my why this code crashes on the ExecSQL statement?
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我试图设置一个已经存在的值
我实际上只需要设置 LASTID
我不敢相信我这样做了
I was trying to set a value that already existed
I actually only needed to set the LASTID
I can't believe I did that