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 2005 Forums
 Transact-SQL (2005)
 Login Validation

Author  Topic 

janets20
Starting Member

12 Posts

Posted - 2010-05-27 : 14:50:38

Hi,

I need to write a Stored Proc to validate the user.The input is username,Password.If their is a valid record return true else false.How to go about it?.


Regards
Janet

Sachin.Nand

2937 Posts

Posted - 2010-05-27 : 14:58:24
[code]
if exists(your authentication query)
Print 'Valid user'
Else
Print 'Invalid user'
[/code]

PBUH
Go to Top of Page

janets20
Starting Member

12 Posts

Posted - 2010-05-27 : 15:09:25
The Stored Proc needs to return a value to a .net application
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-05-27 : 15:25:21
if exists(your authentication query)
select 1
Else
select 0

Then in the .net application use a ExecuteScalar of the command object to check the whether the SP returned 1 or 0.




PBUH
Go to Top of Page

janets20
Starting Member

12 Posts

Posted - 2010-05-27 : 15:58:50
Hi,

I have a SP as

alter PROCEDURE sp_MainLogin
@userid AS VARCHAR(50),
@password AS VARCHAR(50),
@value AS INT OUTPUT
AS
SET @value = 0
if exists (SELECT * FROM testusr WHERE login=@userid AND password=@password)
set @value = 1
GO

when i run as below i am getting ValidUser as null.(user1 has a password test)

DECLARE @OutResult int
exec sp_MainLogin @userid = 'user1' , @password = 'test' , @value=@OutResult
select @OutResult as ValidUser
go


Regards
Janet
Go to Top of Page
   

- Advertisement -