DB2一个删除的问题
我是用ADO连接DB2,在程序中有这样一个操作,即:对一个查询出来的结果集中的记录,一个一个的删除
相关代码如下:
while(m_pRecoreset->State == adStateOpen && !m_pRecoreset->EndOfFile) //m_pRecoreset为_RecordsetPtr类型,为一个select语句查询出来的结果集 { _variant_t tempVariant1,tempVariant2; tempVariant1 = m_pRecoreset->GetCollect(_variant_t((long)0)); tempVariant2 = m_pRecoreset->GetCollect(_variant_t((long)1)); CString strTemp = (LPCSTR)(_bstr_t)tempVariant1; CString strTemp2 = (LPCSTR)(_bstr_t)tempVariant2; 。。。。。。。。。。//省略部分代码 try { m_pRecoreset->Delete(adAffectCurrent); //我想删除当前记录 } catch (_com_error e) { CString strErrDescribe; strErrDescribe.Format("Exception thrown for classes generated by #import" "\tCode = %81x\n" "\tCode meaning = %s\n" "\tSource = %s\n" "\tDescription = %s\n", e.Error(), e.ErrorMessage(), (LPCTSTR)(e.Source()), (LPCTSTR)(e.Description())); TRACE("%s %s\r\n", (LPCTSTR)e.Source(),(LPCSTR)e.Description()); return 0; } m_pRecoreset->Update(); m_pRecoreset->MoveNext(); }