各位高手请指点一二!

解决方案 »

  1.   

    odbc 能报错的吧.....
    看一下ODBC ,SDK上能有
      

  2.   

    1.不要让应用程序这时在有读写数据库操作时发生异常使程序飞掉
    使用try,catch(...)
    2.响应ADO的通知事件(可以参考文档中心里ADO数据库编程入门 )
      

  3.   

    catch(_com_error &e)
        {
            // Notify the user of errors if any.
            _variant_t vtConnect = pRstAuthors1->GetActiveConnection();        // GetActiveConnection returns connect string if connection
            // is not open, else returns Connection object.
            switch(vtConnect.vt)
            {
                case VT_BSTR://这个错误能显示你要的信息
                    erfile=OrderID;
    erfile=erfile+"    ErrorRetCall!Message =";
    erfile=erfile+e.ErrorMessage();
                    erfile=erfile+"  Source = ";
    erfile=erfile+e.Source();
                    erfile=erfile+"  Description =";
    erfile=erfile+e.Description();
    erfile=erfile+"\n";
    if (pRstAuthors1)
    if (pRstAuthors1->State == adStateOpen)
    pRstAuthors1->Close();
    return 1;
                case VT_DISPATCH:
                    PrintProviderError(OrderID,vtConnect);
    if (pRstAuthors1)
    if (pRstAuthors1->State == adStateOpen)
    pRstAuthors1->Close();
    return 1;
                    //break;
                default:
                    erfile=OrderID+"    Errors occured for RetCall().\n";
    if (pRstAuthors1)
    if (pRstAuthors1->State == adStateOpen)
    pRstAuthors1->Close();
    return 1;
                    //break;
            }
    }
        
        if (pRstAuthors1)
            if (pRstAuthors1->State == adStateOpen)
                pRstAuthors1->Close(); return 0;
    }
      

  4.   

    CDatabase db ;
    //  不要使用try 和catch
    TRY
    {
        db.open( ... ) ;
    }
    CATCH (CDBException e)
    {
    }
    END CATCH判断是否连接着
    if (db.IsOpen ())
    {
    }
      

  5.   

    CATCH ( CDBException , e)
    上边写错了
    我这机器上没有msdn,只能凭记忆写了
      

  6.   

    把光标放在CATCH上,按F12,察看它的定义,可以发现这些定义的意思及相关的定义