4,018
社区成员




_RecordsetPtr spRecordset;
if (FAILED(spRecordset.CreateInstance(__uuidof(Recordset))))
{
MessageBox(NULL, _T("Error"), _T("Error"), MB_OK || MB_ICONWARNING);
return 1;
}
//Open the spRecordset;如果不用Open,还有别的替代解决方案吗?
spRecordsetOriginal->Open(_variant_t(_T("select * from student where 0>1")), _variant_t((IDispatch*)pMyConnect, true), adOpenKeyset, adLockBatchOptimistic, adCmdText);
HRESULT hr = spRecordset->AddNew();
assert(SUCCEEDED(hr));
spRecordset->Fields->GetItem(vtIndex0)->Value = _bstr_t("002");
spRecordset->Fields->GetItem(vtIndex1)->Value = _bstr_t("ADO-002");
hr = spRecordset->UpdateBatch(adAffectAll);
assert(SUCCEEDED(hr));