Returning value from stored procedure

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
 
D

Daran Johnson

Jay,

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

-Daran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top