各位大侠,小弟碰到一个问题,狂做没有做出来,请各位大侠帮帮忙:
用ODBC连接的Oracle数据库,怎么在VC里面执行Oracle存储过程!
小弟是这么写的,可是不行!
CDatabase *m_pdb;
m_pdb.Open(.....);
m_pdb.ExcuteSQL("Call Procedure_Name");
谢谢!有分
用ODBC连接的Oracle数据库,怎么在VC里面执行Oracle存储过程!
小弟是这么写的,可是不行!
CDatabase *m_pdb;
m_pdb.Open(.....);
m_pdb.ExcuteSQL("Call Procedure_Name");
谢谢!有分
解决方案 »
- 想利用CPictureEx将网页图片显示到对话框上,出现问题,求指点
- vc9的有一个问题:如何让CFileView 和 CClassView一直保持tab选项卡的方式?或者用那个函数设置成选项卡方式显示?
- 如何将预览框中的图片转化为字符串
- 问个关于'IHTMLElement2' : undeclared identifier的问题
- 重金求助:求高手用VC和OpenGL编程实现地质体三维可视化,薪酬面议!急!!
- 关于线程问题
- 向用VC与mysql数据库编程的高手求助(在线等待)
- 关于头文件包含问题,急,在线等!!!
- 关于调用COM服务器的小问题
- #include<window.h>
- 在VC中用delete对数据库中的记录执行操作时,怎么判断删除成功了呢?又怎么判断删除了几条记录?
- mscomm.create(......)方法中的参数都是什么意思?
//#include "stdafx.h"
#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;
}
路过,如果还有一个输入参数呢?上面代码怎么改?
Cmd1->CommandText = "{call ONEGA.TestProc1( ?)}"; 这是什么?
CrecordSet oSet(m_pdb);
oSet.open("{Call Procedure_Name}");
但是我不知道执行有输出参数的过程怎么写?
还有"{call ONEGA.TestProc1( ?)}"中的?什么意思?怎么把输出参数得到呢?
还请高手指点。
ps:ODBC方法哦!
m_pdb.ExcuteSQL("{Call Procedure_Name}");