_RecordPtr pRec;
//打开一个记录集
pRec->AddNew();
pRec->PutCollect();
//这里有个非空列没有PutCollect
pRec->Update();
这里会拋出一个异常,但是catch(_com_error e)捕捉不到,为什么?

解决方案 »

  1.   

    See http://support.microsoft.com/kb/169498/If the smart pointers detects a negative result, it issues a _com_error error. But there are many other code out there. Function call is subject to fail under stack corruption and buffer overflow, for example.
      

  2.   

    for example:try  
    {  
      pRs->Open(varSTR,varConn,adOpenDynamic,adLockOptimistic,adCmdText);        
    }  
    catch(_com_error  &  e)  
    {  
       MessageBox(e.ErrorMessage());  
    }  
    catch(...)
    {
      MessageBox("unknown exception!");
    }就这样,试试;)
      

  3.   

    很久没有用过addNew了,虽然我都在做数据库应用
    一般都是用连接的
    execute运行INSERT INTO语句插入的