我用adoconnection连接数据库失败,系统报错EOleException,将错误信息加入下列代码中
try ...
except
  on EOleException do ...;
end;
系统提示EOleException错误,请问这是为什么,如何解决?

解决方案 »

  1.   

    你如果要捕捉异常信息,可以将exception的message读出来;
    如果是屏蔽异常信息;
    那就是try..except..end,屏蔽之后直接执行exe就看不到异常了,但是用delphi调试运行时还是会看见异常的!
      

  2.   

    try
    adoconnection1.beginstran;
    do.....
    adoconnection.commitstran;
    except
    adoconnection1.rollbacktran;  //显示错误
    for I := 0 to adoconnection1.Errors.Count - 1 do
        begin
          case AParam.AConnection.Errors[I].NativeError of
            547  : begin
                     if pos('insert',AParam.AConnection.Errors[I].Description) > 0 then
                     begin
                       //'外键约束insert,delete,update';
                       if sErrText <> '' then sErrText := sErrText + #13;
                       sErrText := sErrText + 's';
                     end
                     else
                     if pos('delete',AParam.AConnection.Errors[I].Description) > 0 then
                     begin
                       if sErrText <> '' then sErrText := sErrText + #13;
                       sErrText := sErrText + 's';
                     end
                     else
                     if pos('update',AParam.AConnection.Errors[I].Description) > 0 then
                     begin
                       if sErrText <> '' then sErrText := sErrText + #13;
                       sErrText := sErrText + 's';
                     end;
                   end;//end of 547        945  : begin
                     if sErrText <> '' then sErrText := sErrText + #13;
                     sErrText := sErrText + '您的内存不足!';
                   end;//end of 945        4850 : begin
                     if sErrText <> '' then sErrText := sErrText + #13;
                     sErrText := sErrText + '数据库表被锁定!';
                   end;//end of 1204        2627 : begin
                     if sErrText <> '' then sErrText := sErrText + #13;
                     sErrText := sErrText + '输入的关键属性值已经存在!';
                   end;//end of 2627        7303 : begin
                     if sErrText <> '' then sErrText := sErrText + #13;
                     sErrText := sErrText + '网络初始化失败!请检查网络设置!';
                   end;//end of 7303        10024: begin
                     if sErrText <> '' then sErrText := sErrText + #13;
                     sErrText := sErrText + '网络连接超时!请检查网络设置!';
                   end;//end of 10024        else   begin
                     if
                   end;
          end;//end of case    end;//end of for
        //最后显示错误信息sErrText 
    end;
      

  3.   

    系统提示‘EOleException’这个词错误!是否没定义?