Link to home
Start Free TrialLog in
Avatar of seemad
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,NULL,adCmdStoredProc);
          CString strContent;
/* throws an exception here
          strContent = (char *) (_bstr_t) pRecordset->Fields->GetItem ("bay_no")->Value;

 
               AfxMessageBox(strContent);
          }
thanks in advance
Avatar of MRNMurthy
MRNMurthy
Flag of India image

Hi,

I will try & getback to u with update.

From

MRN Murthy
ASKER CERTIFIED SOLUTION
Avatar of Triskelion
Triskelion
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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