all groups > sql server programming > may 2005 >
You're in the

sql server programming

group:

Creating a Password Retrieval Stored Procedure


Creating a Password Retrieval Stored Procedure EvanK
5/20/2005 8:27:01 PM
sql server programming: I would like to create a stored procedure to pass a login name and password
to and have it verify the info and return a few fields of data back to the
calling function from a javascript page. I have tried a few things but can't
Re: Creating a Password Retrieval Stored Procedure EvanK
5/21/2005 7:38:01 AM
I changed the code as follows:

CREATE PROCEDURE dbo.MM_Chk_User
@UserID varchar(128),
@Password varchar(128)
AS

SET NOCOUNT ON
IF NOT EXISTS
(
SELECT First_Name, Last_Name
FROM LogonNames
WHERE Name = @UserID AND
Password = @Password
)
BEGIN

RAISERROR ('Invalid user or password', 1, 0)

END
SELECT First_Name, Last_Name
FROM LogonNames
WHERE Name = @UserID AND
Password = @Password
GO

I get the following error
[SQL Server]Invalid value 0 for state. Valid ranges is from 1 to 127

[quoted text, click to view]
Re: Creating a Password Retrieval Stored Procedure Dan Guzman
5/21/2005 8:27:25 AM
One method is to use NOT EXISTS:

CREATE PROC MyProc
@UserID varchar(128),
@Password varchar(128)
AS
SET NOCOUNT ON
IF NOT EXISTS
(
SELECT MyData
FROM Users
WHERE UserID = @UserID AND
Password = @Password
)
BEGIN
RAISERROR ('Invalid user or password', 1, 0)
END
SELECT MyData FROM MyTable
GO


--
Hope this helps.

Dan Guzman
SQL Server MVP

[quoted text, click to view]

AddThis Social Bookmark Button