_ConnecttionPtr m_pConnection;
_RecordsetPtr m_pCommand;
_ParameterPtr m_pParameter;已经初始化成功,不带参数的存储过程也能正确调用。
就是不能调用有参数的存储过程。
m_pCommand->Paraters->Refresh();//第一种方式
m_pParameter=m_pCommand->CreateParameter("v_id",adChar,adParamInput,2,"01");
m_pCommand->Parameter->Append(m_pParameter);//第二种方式
m_pCommand->Parameter->Item("v_id")->Value=_variant_("133");\m_pCommand->Excute(NULL,NULL,adCmdStoredProc);excute也设置了各种可能的方法,但不能吧参数传进去,execute抛出异常
_RecordsetPtr m_pCommand;
_ParameterPtr m_pParameter;已经初始化成功,不带参数的存储过程也能正确调用。
就是不能调用有参数的存储过程。
m_pCommand->Paraters->Refresh();//第一种方式
m_pParameter=m_pCommand->CreateParameter("v_id",adChar,adParamInput,2,"01");
m_pCommand->Parameter->Append(m_pParameter);//第二种方式
m_pCommand->Parameter->Item("v_id")->Value=_variant_("133");\m_pCommand->Excute(NULL,NULL,adCmdStoredProc);excute也设置了各种可能的方法,但不能吧参数传进去,execute抛出异常
解决方案 »
- 调试GUI程序时,当F10结束某个函数时,并不能跳转到下一个有效位置,如何继续单步调试?
- OpenGL拾取问题
- 【求助】C++高手们~help 关于启动应用程序
- windows游戏框架
- 在DEV-CPP中编译建立快捷方式代码出现incompatible type for argument 1 of `CoCreateInstance'
- win32汇编程序或c++程序如何实现类似于java中的printStackTrace功能
- 那位大虾有<<MFC Internals>>的下载地址?谢谢指点
- C++多线程编程书籍
- VS2012中的VC++怎么才能让编译器只显示指定源文件中的警告?
- 没有两三年功力别进来---Documnet Template
- 一个简单的问题:怎样获得mouse cursor的尺寸?搞定立刻给分:)
- 子窗口AnimateWindow 等待……
#import "c:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF", "EndOfFile")
VOID PrintProviderError(_ConnectionPtr pConnection)
{
// Print Provider Errors from Connection object.
// pErr is a record object in the Connection's Error collection.
ErrorPtr pErr = NULL;
long nCount = 0;
long i = 0; if( (pConnection->Errors->Count) > 0)
{
nCount = pConnection->Errors->Count;
// Collection ranges from 0 to nCount -1.
for(i = 0; i < nCount; i++)
{
pErr = pConnection->Errors->GetItem(i);
printf("\n\t Error number: %x\t%s", pErr->Number, (LPCSTR)pErr->Description);
}
}
}
/*
CREATE PROCEDURE "ONEGA"."TestProc1"
(
p_out OUT numeric,
p_id IN numeric DEFAULT 1
)
IS
BEGIN
p_out:= p_id + 1234;return;
END ;
*/
int main(int argc, char* argv[])
{
printf("Use ADO to open Oracle!\n");
CoInitialize(NULL);
_ConnectionPtr pConn("ADODB.Connection");
try
{
_CommandPtr Cmd1;
Cmd1.CreateInstance( __uuidof( Command ) );
_ParameterPtr outParam=NULL;
_RecordsetPtr pRst("ADODB.Recordset");
pConn->Open("Provider=OraOLEDB.Oracle;Data Source=workdb;User Id=Onega;Password=sa;"
,"","",adConnectUnspecified);
Cmd1->ActiveConnection = pConn;
Cmd1->CommandText = "{call ONEGA.TestProc1( ?)}";
Cmd1->CommandType = adCmdText;
outParam = Cmd1->CreateParameter("p_out",adInteger,adParamOutput,sizeof(int));
Cmd1->Parameters->Append(outParam);
Cmd1->Execute(NULL,NULL,adExecuteNoRecords);
long p2=Cmd1->Parameters->Item["p_out"]->Value;
printf("p2= %d,\n",p2);
pConn->Close();
}
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
printf("\nCOM error occurred, Source : %s \n Description : %s \n",(LPCSTR)bstrSource,(LPCSTR)bstrDescription);
PrintProviderError(pConn);
}
::CoUninitialize();
printf("program end.\n");
return 0;
}