
New in VBScript - I need to intercept a SQL Stored Proc Return value
Could you not also try this...
Dim MyReturn
'Create a connection and execute SP with Parameters
Set objCmd =
Server.CreateObject("ADODB.Command")
objCmd.ActiveConnection = objConn
objCmd.CommandType = adCmdStoredProc
objCmd.CommandText = mystoredproc_SP
objCmd.Parameters.Append objCmd.CreateParameter("return", adInteger,
adParamReturnValue, 4)
objCmd.Parameters.Append objCmd.CreateParameter("myParam", adVarChar,
adParamInput, 12, myparam)
objCmd.Execute
'Set variable MyReturn equal to the value of the StoredProcedure return
MyReturn = objCmd.Parameters("return").value
If MyReturn = 0 Then
WHATEVER
end if
If MyReturn > 0 Then
WHATEVER
end if
This doesn't require the use of a recordset and I've found that it works
well as long as the return value is always first. Is there a performance
issue in creating it this way?
jay
Quote:
> Hi,
> This may be VBS 101 for many of you but I have the following:
> I have a SQL stored procedure as follow:
> create procedure sp_format_rec as
> /* This sproc contains to return statements */
> .
> .
> return -1
> .
> .
> return 1
> /* End of the sproc */
> In VBS, I would like to capture the returned values of this stored proc,
so
> I created the following script:
> Dim ObjConn
> Set ObjConn = CreateObject("ADODB.Connection")
> ObjConn.Open "Provider=SQLOLEDB; Data Source ..."
> SQLStmt = "EXEC sp_format_rec"
> ObjConn.Execute SQLStmt,,AdExecuteNoRecords
> ObjConn.Close
> set ObjConn = Nothing
> Where or how do I capture the returned values?
> Much thanks for your time and help.