Delphi ADOConnection 捕捉错误

procedure TForm1.con1ExecuteComplete(Connection: TADOConnection;
RecordsAffected: Integer; const Error: Error;
var EventStatus: TEventStatus; const Command: _Command;
const Recordset: _Recordset);
begin
mmo1.Lines.Add('con1ExecuteComplete');
if Error = nil then
EXIT;
if Error.SQLState = '08S01' then //连接失败 其他状态得去查一下资料才能做对应的处理
begin
Connection.Close;
Connection.Open;
end;
mmo1.Lines.Add('Source:'+Error.Source);
mmo1.Lines.Add('Description:'+Error.Description);
mmo1.Lines.Add('HelpFile:'+Error.HelpFile);
mmo1.Lines.Add('SQLState:'+Error.SQLState);
mmo1.Lines.Add(inttostr(Ord(EventStatus)));
end;

posted @ 2022-06-05 15:10  Tag  阅读(142)  评论(0编辑  收藏  举报