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] "Dan Guzman" wrote:
> 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
>
> "EvanK" <EvanK@discussions.microsoft.com> wrote in message
> news:210A9660-5874-4AA0-9DF9-1CFE9487868B@microsoft.com...
> >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
> > seem to verify the data and return a value to verify the data.
>
>
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] "EvanK" <EvanK@discussions.microsoft.com> wrote in message
news:210A9660-5874-4AA0-9DF9-1CFE9487868B@microsoft.com...
>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
> seem to verify the data and return a value to verify the data.