I'd like to retrieve both a recordset and the output parameter from a
SQL stored procedure. I can do one or the other but not both. The
stored procedure itself is a simple query with an input and output
parameter.
The parameters:
oCmd.Parameters.Append oCmd.CreateParameter("@ID", adVarChar,
adParamInput, 15 , "9123456")
oCmd.Parameters.Append oCmd.CreateParameter("@Return_Code", adVarChar,
adParamOutput, 50, "")
If I use:
oCmd.Execute
I can read the output parameter using:
wscript.echo oCmd.Parameters("@Return_Code").Value
or
wscript.echo oCmd.Parameters(1).Value
If I use:
set rs = oCmd.Execute
I can loop through the recordset and correctly display the data. I
can't display the output parameter.
I tried to use:
Set rs = rs.NextRecordset
wscript.echo oCmd.Parameters("@Return_Code").Value
wscript.echo oCmd.Parameters(1).Value
That doesn't work.
I then tried to close the recordset:
Set rs = rs.NextRecordset
rs.close
wscript.echo oCmd.Parameters("@Return_Code").Value
wscript.echo oCmd.Parameters(1).Value
To no avail.
I did set nocount in the stored procedure. I can get either the
output data or the recordset data so the stored procedure is returning
the data to my script.
At this point all I want to return is "Hello world" from the stored
procedure.
I'm new to the world of running stored procedures from vbscript,
though I have been running queries for a long time. Any ideas?
Swyck