try
{
pconnection -> excuse(select * from Table);//如果表名不存在,为什不进catch(_com_error);
}
catch(_com_error)
{
   
}请高手指点??

解决方案 »

  1.   

    刚才试了一下,是好象不会抛出 _com_error 类型的错误。
      

  2.   

    catch(_com_error &e)
    {.....
    }
      

  3.   

    在C/C++ 环境下,默认是尽量返回HRESULT类型的错误码而不是抛出异常.
    这是因为try{}catch(){}的性能很差.(10~100倍的差距)execute 就是直接返回错误码的要想抛出异常就用if( FAILED(x) )_com_issue_error(x);例如:
    #define TESTHR(x) if FAILED(x) _com_issue_error(x)
    try{
    TESTHR( pconnection -> excuse(select * from Table) );
    }
    catch(_com_error& e )
    {
      ...
    }
    如此即可