天天看點

_RecordsetPtr異常捕獲

try
{
    _RecordsetPtr    rec;                //結果集
    ...
    
  //通過這種方式可以處理 錯誤代碼: 800a0e79  對象打開時,不允許操作
    if (m_pRec->State == adStateOpen) 
        m_pRec->Close();
            
    rec->Open(_bstr_t(xmlfile), "provider=MSPersist", adOpenKeyset, adLockOptimistic, adCmdFile);

}
catch(_com_error &e)
{
    CString szTemp;
    szTemp.Format("錯誤代碼: %08lx  ", e.Error());
    szTemp += e.Description()+e.ErrorMessage();
}
catch(...)
{
    strMsg.Format("打開XML檔案[%s]未知異常,原因:%d", strFullXmlFile, GetLastError());
}