adoconnection断线重连

 

adoconnection断线重连

通过捕获数据库断连的异常,实现重连。

procedure TForm1.ApplicationEvents1Exception(Sender: TObject;
E: Exception);
begin
if (ADOConnection1.Errors.Count > 0) and (ADOConnection1.Errors.Item[0].Number = -2147467259) then
begin
ADOConnection1.Close;
ADOConnection1.Open;
end;
end;