[求助]如何在VC里调用ORACLE?
刚刚入门ORACLE,想用VC调用一下自己建的数据库,请各位高手帮帮忙,只需要知道具体怎么去实现……谢谢啦
#include<iostream.h>
#include<stdio.h>
#include <afx.h>
#include <comutil.h>
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","rsEOF")
void main()
{
try
{
_CommandPtr cmmd;
CoInitialize(NULL);
_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset));
HRESULT hr = cmmd.CreateInstance(__uuidof(Command));
_ParameterPtr param;
// 设置ADO入参
param = cmmd->CreateParameter("Pi_Serviceid",adVarChar,adParamInput,4,"2022");
param = cmmd->CreateParameter("pi_BranchCode",adVarChar,adParamInput,9,"8884");
。。。。。。。。。。。。。。。。。。。。
// 设置ADO出参
param = cmmd->CreateParameter("Po_Returncode",adVarChar,adParamOutput,4, _variant_t(_bstr_t(Po_Returncode)));
cmmd->Parameters->Append(param);
param = cmmd->CreateParameter("po_Debit",adVarChar,adParamOutput,16,_variant_t(_bstr_t(po_Debit)));
cmmd->Parameters->Append(param);
;;;;;;;;;;;;;;;;;;
// 连接数据库
cmmd->CommandText=_bstr_t("P_TRD_SUBANDBIDS");// 存储过程名称
pConn->ConnectionString="Provider=MSDAORA;Data Source =ora92"; // 数据库连接串
pConn->Open(pConn->ConnectionString,"zx_icbc","zxicbc",adConnectUnspecified);
cmmd->ActiveConnection = pConn;
// 执行存储过程
cmmd->CommandType=adCmdStoredProc; // 定义执行类型
cmmd->Execute(NULL, NULL, adCmdStoredProc); // 执行存储过程
// 获取出参
_variant_t Final;
CString strValue;
Final = cmmd->Parameters->GetItem("Po_Returncode")->GetValue();
strValue = (LPCTSTR)(_bstr_t(Final));
// 关闭数据库连接
pConn->Close();
pRst.Release();
pConn.Release();
CoUninitialize();
}
catch (_com_error& e)
{
cout<<e.ErrorMessage()<<endl;
cout<<e.Description()<<endl;
}
}
使用ADO连接ORA数据库 执行存储过程的例子,刚写的