急!!大家帮帮我
我的存储过程返回结果集,在查询分析器里运行正常,可是用VC调用存储过程,当运行到“if(!pRs->GetadoEOF())”时,总是提示:"对象关闭时,操作不被允许!"错在哪里呀,求大家帮帮我。
VC调用过程如下:
_CommandPtr m_pCommand;
m_pCommand.CreateInstance(__uuidof(Command));
_ParameterPtr param;
param = m_pCommand->CreateParameter("",adVarChar,adParamInput,m_sContractNo.GetLength()+1,_variant_t(m_sContractNo));
m_pCommand->Parameters->Append(param);
m_pCommand->Parameters->Refresh();
m_pCommand->CommandText=_bstr_t("GET_REPORT");//存储过程的名称
m_pCommand->ActiveConnection = theApp.m_pConn; //需要使用的ADO连接
m_pCommand->CommandType=adCmdStoredProc;
_RecordsetPtr pRs;
try
{
pRs=m_pCommand->Execute(NULL, NULL,adCmdStoredProc);
if(!pRs->GetadoEOF())
{
pRs->MoveFirst();
.....
}
m_pCommand.Detach();
}
catch(_com_error &e)
......