1.设置 pRecord->CursorLocation = adUseClient;
2.open方法中设置lockType 为adLockBatchOptimistic
_RecordsetPtr pRecord; pRecord.CreateInstance("ADODB.Recordset"); pRecord->CursorLocation = adUseClient; CString strSQL ; strSQL.Append("SELECT * fROM emp "); try { pRecord->Open(_bstr_t(strSQL),pConnection.GetInterfacePtr(),adOpenStatic,adLockBatchOptimistic,adCmdText); CString strValue; while(!pRecord->AdoEOF) { strValue.Format("Test_%d",pRecord->AbsolutePosition); pRecord->PutCollect("name",_variant_t(strValue)); pRecord->MoveNext(); } pRecord->UpdateBatch(adAffectAll); pRecord->Close(); } catch(_com_error &e) { OutputDebugString(e.Description()); }
时间: 2024-11-30 03:00:08