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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Get a Return code from a SQL Stored Proc

Status
Not open for further replies.

joebickley

Programmer
Aug 28, 2001
139
GB
Hi I have a stored procedure that i send some params to and it does a whole load of processesing. Within that it has some Return commands to stop the process dead and return a number. If i used the SQL query analyser i can see this on the screen but how can i pick it up when calling it from access VBA?

Any help would be appreciated

Thanks
Joe
 
This a frag is more a less from a book whose name I have forgotten. It might be "Access 2000 Client/Server"

Function ExecuteSProc(ByVal procnam As String) As Integer


Dim adocommand As New ADODB.Command
Dim adoparam As ADODB.Parameter

On Error GoTo err_h

With adocommand

Set adoparam = .CreateParameter("RETURN_VALUE", adInteger, adParamReturnValue, , Null)

.Parameters.Append adoparam
.CommandText = procnam
.CommandType = adCmdStoredProc
.ActiveConnection = SqlServer
.Execute

End With

ExecuteSProc = adocommand("RETURN_VALUE")

Exit Function

err_h:
MsgBox Error$


End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top