Returning value from stored procedure

  • Thread starter Thread starter jay
  • Start date Start date
J

jay

This seems to have been discussed before, but I am still
having trouble getting it to work.

This is the VBA:
Dim rst As New ADODB.Recordset
Dim cmd As New ADODB.Command
Dim rv As Long

With cmd
.ActiveConnection = CurrentProject.Connection
.Parameters.Refresh
.CommandText = "createTemplate"
.CommandType = adCmdStoredProc
.Parameters.Append cmd.CreateParameter("name",
adVarChar, adParamInput, 50, name)
End With


Set rst = cmd.Execute 'actually no recordset returned
by this one


So far so good. This particular SP does not return a
recordset but does return an integer using the RETURN
syntax.

Somewhere on this list was a suggestion to add:

rv = cmd.Parameters("@return_value")

without any formal declaration, but this fails with the
error: "Item cannot be found in the collection
corresponding to the requested name or ordinal"

What am I missing?

Jay
 
Jay,

You need to declare another parameter and specify it as a return value.

-Daran
 
Back
Top