[thelist] capturing returned value from MS-SQL stored procedure
spinhead
evolt at spinhead.com
Thu Jan 10 17:42:24 CST 2002
I've been fighting this for a while, using workarounds, but it's time to
figger it out. I'm inserting (in this case) a request number (po_ID) into a
table (PO_number) which only has two fields. The other field (pon_ID) should
autoincrement and return the newly created value.
Here's my stored proc:
=======================
CREATE PROCEDURE sp_pon_Add
(
@po_ID int,
@RetVal int output
)
As
Begin Transaction
Insert into PO_number (po_ID)
Values (@po_ID)
Select @RetVal=@@Identity
If @@Error <> 0 Goto Tran_Abort
Commit Transaction
Goto Success
Tran_Abort:
RollBack Transaction
Set @RetVal=0
Return 0
Success:
Return 1
=======================
and here's the code in the page
=======================
strQuery = "DECLARE @PonID int EXECUTE sp_pon_Add " & strPoID & ", @RetVal
= @PonID OUTPUT"
Set AddPON = objConn.Execute(strQuery)
=======================
So now, how do I get the value of @PonID into a VBScript variable? I tried
this
strPonID = @PonID
and
strPonID = AddPON(@PonID)
and get told that '@' is an invalid character. Tried
strPonID = AddPON("@PonID") and got the error
Item cannot be found in the collection corresponding to the requested name
or ordinal.
Help me help me. And, thanks.
joel
More information about the thelist
mailing list