小妹有一事求各位大虾:AD0调用有返回结果集存储过程;如果存储过程内部有(insert,update)等操作,则调用->GetRecordCount()时报“Operation is not allowed when the object is closed” 我的程序如下:
_RecordsetPtr &recordset;
_CommandPtr &command;
command 已经打开。
_variant_t vtEmpty (DISP_E_PARAMNOTFOUND, VT_ERROR);
recordset->put_CursorLocation(adUseClient);
recordset->Open((_variant_t((IDispatch * command)),vtEmpty,adOpenStatic,adLockOptimistic, adCmdUnspecified);
如果存储过程内部没有(insert,update)等操作。则可以得到结果集。->GetRecordCount()也正确。
_RecordsetPtr &recordset;
_CommandPtr &command;
command 已经打开。
_variant_t vtEmpty (DISP_E_PARAMNOTFOUND, VT_ERROR);
recordset->put_CursorLocation(adUseClient);
recordset->Open((_variant_t((IDispatch * command)),vtEmpty,adOpenStatic,adLockOptimistic, adCmdUnspecified);
如果存储过程内部没有(insert,update)等操作。则可以得到结果集。->GetRecordCount()也正确。
recordset->Open((_variant_t((IDispatch * command)),vtEmpty,adOpenStatic,adLockOptimistic, adCmdUnspecified);
open()的第一个参数有用command的吗?换成这个试试看:
recordset = command->Excute( _bstr_t CommandText, VARIANT * RecordsAffected,
long Options );
参数你自己根据情况设定吧。
recordset->Open((_variant_t((IDispatch * command)),vtEmpty,adOpenStatic,adLockOptimistic, adCmdUnspecified);
你可以查一下ADO的帮助,不好意思我没有碰到过,以前也写过这个东东,但是没有出现你说的
问题!