delphi adoconnection断线重连


本文整理自网络,侵删。

 
adoconnection断线重连


uses ComObj;


procedure TForm1.ApplicationEvents1Exception(Sender: TObject; E: Exception);
var
  I: integer;
begin
  //请执行如下命令或者其他方法强制产生数据库连接断开情况,以触发如下异常。
  //net stop MsSqlServer
  //net start MsSqlServer
  if (E is EOleException) and ((E as EOleException).ErrorCode= -2147467259) then
  begin
    ADOConnection1.Connected := False;
    try
      ADOConnection1.Connected := True;
    except On E2: Exception do
    begin
      MessageDlg('重连数据库发生错误:'#13 + E2.Message, mtError, [mbOK], 0);
    end;
    end;
  end;
end;

来源https://www.cnblogs.com/hnxxcxg/p/12418507.html

相关阅读 >>

Delphi datasnap 2009的简单使用

Delphi 获取外部程序句柄与发送消息

Delphi调用游戏call代码

Delphi正则表达式匹配中文

Delphi 模拟按键的一些误解

Delphi sametext

Delphi 将memo转化为jpg输出

Delphi 禁止用键盘左右箭头,去切换pagecontrol页签

Delphi idhttp访问datasnap有密码验证的中间件

Delphi 动态设置屏幕分辨率

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...