try
....
Except
on EDatabaseError do
begin
Application.MessageBox('错误:数据库读取失败.建议您检查网络的连接情况!',
'连接错误',MB_OK+MB_ICONWARNING);
abort;
end;
end;
....
Except
on EDatabaseError do
begin
Application.MessageBox('错误:数据库读取失败.建议您检查网络的连接情况!',
'连接错误',MB_OK+MB_ICONWARNING);
abort;
end;
end;
Database1.Connected:=true;
楼上说的对,在程序中,无论是自定义异常,还是vcl异常,在调试状态下一定会先弹出Delphi的提示框的,你可以关闭调试情况下的这个选项.
procedure button1.onclick
begin
Application.Onexception=appException;
Database1.conntected:=true;
//free and nil,不能它是整个Application的Exception处理过程.
application.onException:=nil;
end;
procedure tform1.appexception(var msg:TMsg;var done:boolean);
begin
showmessage('hello,there is a error');
end;
try
Query1.Open();
except
on e:Exception do begin
result := false;
MessageBox(handle, '数据库操作失败。', '失败' , MB_OK + MB_ICONEXCLAMATION);
exit;
end
..........OK?