我是用ADO连接DB2,在程序中有这样一个操作,即:对一个查询出来的结果集中的记录,一个一个的删除
相关代码如下:
- SQL code
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(); }
此处捕获异常为:当前记录集不支更新,这可能是提供程序的限制,也可能是选定锁定类型的限制
不是很明白这错误的原因,哪位高手指点一下
谢谢了
------解决方案--------------------------------------------------------
似乎程序问题把
试问 在结果集中能够重新查询更新吗? 更新完了 在movenext 那么当前游标在何处?