C++ ado 如何得到返回的结果集
我写了一个存储过程。如下:
create or replace procedure pro_testTable
(
pcurse out sys_refcursor
)
as
begin
open pcurse for
select * from 测试表;
end;
在数据库中测试此存储过程正确.
MFC代码
_CommandPtr pCmd;
pCmd.CreateInstance(__uuidof(Command));
_RecordsetPtr pRecordset = NULL;
pRecordset.CreateInstance(__uuidof(Recordset));
pCmd->ActiveConnection = m_pConnection;// m_pConnection数据库连接.没有问题
pCmd->CommandType = adCmdStoredProc;
pCmd->CommandText=_bstr_t("pro_testTable");//
try
{
pRecordset = pCmd->Execute(NULL,NULL,adCmdStoredProc);
}catch(_com_error e)
{
pRecordset=NULL;
CString b =e.ErrorMessage();
pCmd=NULL;
}
MFC代码部份在执行增加的存储过程时没有问题,但是执行查询的时候就出问题.e.ErrorMessage()的提示是:
IDispatch error #3092
个人感觉是返回值的问题。是因为没有设置输出参数吗。我也想设置不过不知道结果集是什么类型。请大家帮帮我,谢谢