Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 RETURN value & recordset @ the same time??

Author  Topic 

Jay B. Davis
Starting Member

1 Post

Posted - 2000-11-21 : 21:48:25
I have the following asp code:

Set rsUserId = Server.CreateObject("ADODB.RecordSet")
Set objCmd = Server.CreateObject("ADODB.Command")
With objCmd
.ActiveConnection = objConn
.CommandType = adCmdStoredProc
.CommandText = "IsValid_SP"
.Parameters.Append objcmd.CreateParameter("return",adInteger, adParamReturnValue, 4)
.Parameters.Append objCmd.CreateParameter("@username", adVarChar,adParamInput, 50, username)
.Parameters.Append objCmd.CreateParameter("@password", adVarChar,adParamInput, 8, Useremail)
end With
Set rsUserId = objCmd.Execute

myid = rsUserId

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

**********************************************************
The following is my Stored Procedure Code:

CREATE PROCEDURE dbo.IsValidLogon_SP
@UserName varchar(50),
@Password varchar(25)

AS

if exists(Select * From tblStudents
Where UserName = @UserName
And
Password = @Password)

begin

Select u_id From tblStudents
Where UserName = @ UserName
return(1)

end

else

begin
INSERT INTO FailedLogons(UserName, Password)
values(@UserName, @Password)
declare @totalFails int
Select @totalFails = Count(*) From FailedLogons
Where UserName = @UserName
And dtFailed > GetDate () -1

if (@totalFails >3)
Update tblStudents Set Active = 0
Where UserName = @UserName
return(0)
end

The stored procedure runs in QueryAnalyzer, but when the ASP page is ran I get no return value to assign to IsValid. Dependant on the value of IsValid the code proceeds further.

The program runs now with three separate calls to the db. One with the return parameter only, one to login the user and the other actually returning a recordset with the user's id number. I want to combine into one call and one stored procedure.


Jay
   

- Advertisement -