Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve the return value from a SQL Server stored procedure

Status
Not open for further replies.

juanfiesta

Technical User
Jul 15, 2010
2
US
I need to use an Access 2007 front end to allow users to initiate processes on a SQL Server 2005 database. In most cases, the initiation will involve passing a parameter or two. The SP(s) will not generate data back but will generate return codes to indicate success, failure, etc. and provide them via the T-SQL Return. How do I set up the call to the SP so that I can retrieve the return code.

TIA,

John
 
"Classic" way to call a sp:
Code:
Dim cmdSP as New ADODB.Command
Dim lngRetVal as Long
With cmdSP
   .ActiveConnection=CurrentProject.Connection
   .CommandText = "YourSpName"
   .CommandType = adStoredProc
   .Parameters.Refresh
   '.Parameters("@SomeInputParam")="SomeValue"
   .Execute
   .lngRetval=.Parameters(0)
   'or lngRetVal = .Parameters("@Return_value")
End With

Good luck!

[pipe]
Daniel Vlas
Systems Consultant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top