【问题标题】:Help with Parameterized Query (using Delphi 7 and BDE)参数化查询帮助(使用 Delphi 7 和 BDE)
【发布时间】:2011-02-08 14:22:55
【问题描述】:

有人可以帮我解释一下为什么这段代码在 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;  

【问题讨论】:

  • 没关系,我的错,我发现了我的错误

标签: delphi delphi-7 parameterized bde tquery


【解决方案1】:

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

Set TABLENAME =:ATableName  

其实我只需要设置LASTID

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

我不敢相信我做到了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-09
    • 1970-01-01
    • 2011-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-06
    相关资源
    最近更新 更多