seemad
asked on
calling oracle stored procedues from VC++ using ADO
Hello,
I am using VC++ 6.o and trying to call oracle stored procedures with ADO.
I have attached the below code which is executed after establishing a connection with the database using a ODBC driver.
this code throws an exception when i am trying to retrieve the record set.
also can u suggest some sites/books anything else for my reference.
the procedure "spproc" is as below:
/**********************
create procedure spproc
num number;
begin
select bay_no into num from bay_dtl where rownum =1;
end;
/*****************
the bay no is an integer in the bay_dtl table.
/*********code*********
try
{
_CommandPtr pCommand;
_ParameterPtr pParam1;
HRESULT hr = pCommand.CreateInstance (__uuidof (Command));
if (FAILED (hr))
{
AfxMessageBox ("Can't create an instance of Command");
return;
}
pCommand->ActiveConnection = m_pConn;
pCommand->CommandText = "spproc";
pCommand->CommandType = adCmdStoredProc;
_RecordsetPtr pRecordset;
hr = pRecordset.CreateInstance (__uuidof (Recordset));
if (FAILED (hr))
{
AfxMessageBox ("Can't create an instance of Recordset");
return;
}
pRecordset = pCommand->Execute(NULL,NUL L,adCmdSto redProc);
CString strContent;
/* throws an exception here
strContent = (char *) (_bstr_t) pRecordset->Fields->GetIte m ("bay_no")->Value;
AfxMessageBox(strContent);
}
thanks in advance
I am using VC++ 6.o and trying to call oracle stored procedures with ADO.
I have attached the below code which is executed after establishing a connection with the database using a ODBC driver.
this code throws an exception when i am trying to retrieve the record set.
also can u suggest some sites/books anything else for my reference.
the procedure "spproc" is as below:
/**********************
create procedure spproc
num number;
begin
select bay_no into num from bay_dtl where rownum =1;
end;
/*****************
the bay no is an integer in the bay_dtl table.
/*********code*********
try
{
_CommandPtr pCommand;
_ParameterPtr pParam1;
HRESULT hr = pCommand.CreateInstance (__uuidof (Command));
if (FAILED (hr))
{
AfxMessageBox ("Can't create an instance of Command");
return;
}
pCommand->ActiveConnection
pCommand->CommandText = "spproc";
pCommand->CommandType = adCmdStoredProc;
_RecordsetPtr pRecordset;
hr = pRecordset.CreateInstance (__uuidof (Recordset));
if (FAILED (hr))
{
AfxMessageBox ("Can't create an instance of Recordset");
return;
}
pRecordset = pCommand->Execute(NULL,NUL
CString strContent;
/* throws an exception here
strContent = (char *) (_bstr_t) pRecordset->Fields->GetIte
AfxMessageBox(strContent);
}
thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
By the way...
The example you'll want to see is at the bottom of that page.
I found it using this AltaVista search
http://www.altavista.com/sites/search/web?q=%22oracle+stored+procedure*%22+AND+%22ODBC%22+AND+%22result*set%22+AND+%22CRecordset%22%0D%0A&kl=XX&search=Search&r=&dt=&d0=&d1=&d2=0&sc=&kl=XX&nbq=10&pg=aq
The example you'll want to see is at the bottom of that page.
I found it using this AltaVista search
http://www.altavista.com/sites/search/web?q=%22oracle+stored+procedure*%22+AND+%22ODBC%22+AND+%22result*set%22+AND+%22CRecordset%22%0D%0A&kl=XX&search=Search&r=&dt=&d0=&d1=&d2=0&sc=&kl=XX&nbq=10&pg=aq
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by: Triskelion
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Roshan Davis
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by: Triskelion
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Roshan Davis
EE Cleanup Volunteer
I will try & getback to u with update.
From
MRN Murthy