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

sql server programming

group:

Check for username


Check for username Ed_P.
2/4/2005 9:27:27 PM
sql server programming:
Hello,

I have the following Table:

CREATE TABLE [dbo].[tb_User] (
[usr_id] [int] IDENTITY (1, 1) NOT NULL ,
[usg_groupID] [int] NOT NULL ,
[usr_createdBy] [int] NOT NULL ,
[usr_isActive] [int] NOT NULL ,
[usr_dateCreated] [datetime] NOT NULL ,
[usr_userName] [varchar] (25) NULL ,
[usr_password] [varchar] (50) NULL ,
[usr_firstName] [varchar] (50) NULL ,
[usr_lastName] [varchar] (50) NULL ,
[usr_eMail] [varchar] (50) NULL ,
[usr_phoneNumber] [varchar] (50) NULL ,
[usr_notes] [varchar] (512) NULL
)

I want to set up a stored procedure that will take two parameters
(@UserName varchar(50) and @Password varchar(50)) that I want to use to
check for the following

1. Check to see that the username exisits and that the column isActive = 1
2. If step 1 is true, then check that the @Password Parameter is the
same for the user
3. If step 2 above is true return 1
4. If step 1 about is false (either the username does not exist, of if
it does it's not active (isActive = 0) return 0

I am going to use the Return value in my C# application to warn the user
that either the username does not exist, or it's not active or the
password is wrong.

Re: Check for username oj
2/4/2005 11:20:00 PM
It would be simple as this:

e.g.
create proc usp
@user varchar(25),
@pass varchar(50)
as
set nocount on
if exists(select 1 from tb_User where usr_userName=@user and usr_isActive=1
and usr_password=@pass)
return 0
else
return 1
go


--
-oj


[quoted text, click to view]

AddThis Social Bookmark Button