We help IT Professionals succeed at work.

C++ ADO stored procedure CALL format

Last Modified: 2013-11-20

I am trying to pass 4 values to a EXECUTE stored procedure and then call open.  I get an exception thrown saying that it is expecting the name of the table.

Can anyone help me reformat this?

I have tried the rs.Execute("name"); command and it does not throw an exception but am not able to get at the returned values from the DB table.

thanks in advance....



CString tempstr, _tool, _pm, _device, _operation;
      _tool = "A";
     _pm = "2";
     _operation = "all"    
tempstr.Format("DECLARE  @slope float, @intercept float,  @angle int\n"
"EXECUTE sp_IONMILL_BEAMANGLE '%s', '%s', '%s', '%s' , @slope , @intercept, @angle",
                              _tool, _pm, _device, _operation);

  Open DSN database
CDatabase *pWaferDB=new CDatabase();
if(pWaferDB->OpenEx("DSN=RecipeDatabase;Trusted Connection = trusted") == 0)
      errMsg="Can not open tblBeamAngle table from RecipeDatabase";
      delete pWaferDB;
      return -99;

  Open Table with SQL query
CRecordset rs(pWaferDB);
if(!rs.Open(CRecordset::forwardOnly, tempstr))
      errMsg = "Can not open tblBeamAngle table from RecipeDatabase";
      AfxMessageBox(errMsg, MB_OK);
      delete pWaferDB;
      return -99;
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)



Is it better to use a RecordSet or SmartPointers to call a stored procedure using C++?  I am passing 4 parameters to the in put and recieving 3 in return.

thanks in advance..

I dont't know what a smartpointer is but in VB, if you are not expecting a table back, only parameterd, then it is indeed best to NOT use a recordset - use the command object with the parameters collection.

This may be of assistance:


Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.