如何捕捉错误,例如连接数据库登陆失败或想创建数据库已存在的数据库,错误都是提示Class EOleException,如何区分这两个错误呢,谢谢您的帮助
用下列语句不能区分:
try except
on EOleExceptiondo
showmessage('HaHa');
...
end;
用下列语句不能区分:
try except
on EOleExceptiondo
showmessage('HaHa');
...
end;
解决方案 »
- delphi ServerSocket 如何在stThreadBlocking方式下接受客房端的发来的信息
- 如何判断一点是在一条直线的哪一端?
- 怎样用SQL语句向一个含有自动编号字段的表中插入一条记录
- 高分求能将vcd(.dat文件)转换成asf、wma等流媒体文件的控件
- 很郁闷一问题,几天没睡好觉,不解。请大家多指教。
- 如何Delphi在延时,不使用Application.ProcessMessage;
- 能否在程序中通过serversocket设定发送出去的包在tcp/ip网络中的存活时间?
- sybase的sa密码忘了,有什么好方法可以进入sybase???
- 请各位大虾进来看看,急急急!!!
- delphi中对应与VBScript中的MID函数的是什么?
- 不能关机???
- 我安装ehlib时总是出错,谁能说一下ehlib是怎样安装的 ?谢谢!
try
……
except
on E:EOleException do
begin
case E.Errors[0].ErrorCode of
xxx:showmessage();
yyy:showmessage();
end;
end;
end;
……
except
on E:EOleException do
begin
case E.Errors[0].ErrorCode of//这里出错,errors没定义
xxx:showmessage();
yyy:showmessage();
end;
end;
end;
有问题请发信息到我的E-mail:[email protected]
//连接
execpt
//处理所有错误
end
这样肯定能捉到连接错误,管它是什么错误类型。
on E:EOleException do
begin
case E.ErrorsCode of
xxx:showmessage();
yyy:showmessage();
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
e:EOleException;
begin
try
ADOConnection1.Connected:=true;
except
on E:EOleException do
begin
case E.ErrorCode of
-2147467259:showmessage('未发现数据源!');
-2147217843:showmessage('无效的登录名/口令');
else
showmessage('错误代码:'+inttostr(E.ErrorCode));
end;
end;
end;
end;