September 30, 2010 at 4:23 pm
Hi bit of a long question here i know but i wanted to make sure you had all the info, I am trying to send data to an SQL stored procedure and return a value to my asp page based on the results.
----------------------------------------------------------------------
@Username varchar(12),
@Password varchar(12),
@Return varchar(20) Output
AS
Select *
From tblUsers
Where Username Like @Username AND Password Like @Password
Select @Return = @@rowcount
Return @Return
----------------------------------------------------------------------
This should return 1 if the username and pass are correct and 0 if incorrect if i understand it correctly.
----------------------------------------------------------------------
ASP Code
paramOutput = cmdStoredProc.CreateParameter("@Return", adchar, adParamOutput, 20, "")
cmdStoredProc.Parameters.Append(paramOutput)
Response.Write(cmdStoredProc.Parameters("@Return").Value)
This is the asp code im using to create, pass and retrieve the variable
When i run the SP on the server it executes perfectly and gives me 1 when i use the correct details and 0 when i dont, but when i do the same from asp it returns 0 all the time. sorry for the long post but any help is appreciated
Thanks in advance
September 30, 2010 at 4:51 pm
You should really use a bit data type if that is all you expect to return. I would also use the SET command to set the value, and then the last query, simply use SELECT @InsertSuccessful
Oh yes, I would change the name of the @Return variable to something other than a reserved word.
Andrew SQLDBA
October 2, 2010 at 3:17 am
Thanks for your replies i have got it working now, only question is when i use Set for variables it says no longer supported
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply