添加一个ApplicationEvens(Additional页上)控件 在OnException事件里写: if (E is EOleException) and (pos('连接失败', E.Message) > 0) then if Application.messagebox('数据库服务器连接已断开,是否重新连接?', 'PAP提示', MB_OKCANCEL or MB_ICONERROR or MB_TOPMOST) = IDOK then begin //这里写重新连接的代码 比如: Adoconnection.Connected:=true; end;
在OnException事件里写:
if (E is EOleException) and (pos('连接失败', E.Message) > 0) then
if Application.messagebox('数据库服务器连接已断开,是否重新连接?',
'PAP提示',
MB_OKCANCEL or MB_ICONERROR or MB_TOPMOST) = IDOK then
begin
//这里写重新连接的代码
比如:
Adoconnection.Connected:=true;
end;