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.
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?.RegardsJanet |
|
Sachin.Nand
2937 Posts |
Posted - 2010-05-27 : 14:58:24
|
[code]if exists(your authentication query)Print 'Valid user'ElsePrint 'Invalid user'[/code]PBUH |
|
|
janets20
Starting Member
12 Posts |
Posted - 2010-05-27 : 15:09:25
|
The Stored Proc needs to return a value to a .net application |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-05-27 : 15:25:21
|
if exists(your authentication query)select 1Elseselect 0Then in the .net application use a ExecuteScalar of the command object to check the whether the SP returned 1 or 0.PBUH |
|
|
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 ASSET @value = 0 if exists (SELECT * FROM testusr WHERE login=@userid AND password=@password) set @value = 1GOwhen 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=@OutResultselect @OutResult as ValidUsergoRegardsJanet |
|
|
|
|
|