Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp + sql server stored procedure not returning a value

Status
Not open for further replies.

mit99mh

Programmer
Sep 24, 2002
246
GB
hi I thought I followed to the "T" how to return a value from stored produre but an empty value is returned.

Any help much appreciated:

ASP:
objCM.ActiveConnection = Application("strConn")
objCM.CommandText = "CS_insertUsers"
objCM.CommandType = adCmdStoredProc

objCM.Parameters.Append objCM.CreateParameter("return", adInteger, adParamReturnValue, 4)
objCM.Parameters.Append objCM.CreateParameter("@ID", adInteger, adParamInput, 4, ID )

IsValid = objCM.Parameters("return").Value

objCM.Execute

Response.write "IsValid Type " & VarType(IsValid) & " IsValid " & IsValid & " here"


SP:
CREATE PROCEDURE CS_insertUsers
@ID int
AS

if exists(Select * From CS_users WHERE id = @ID)
return(1)

else
return(0)

GO
 
You should set IsValid after you have run the SP

objCM.Execute

IsValid = objCM.Parameters("return").Value

How can it know what the value is before you have executed the Stored procedure?

Hope this helps,

Chris Dukes
 
Thanks a lot Chris - that sorted it I think I've got a touch of code-blindness
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top