Click here to Skip to main content
15,896,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
CREATE PROCEDURE [dbo].[Proc_Verify_Password]
    @username VARCHAR(20),
    @password varchar(20)
AS
BEGIN

SET NOCOUNT ON

IF EXISTS(SELECT * FROM Authentication_Detail WHERE UserName = @username AND password = @password)
    SELECT '1' AS UserExists
ELSE
    SELECT '0' AS UserExists

END


Here, stored procedure didn't work for correct username and password.. please give me a solution for this..
Posted
Comments
Tomas Takac 18-Feb-15 4:57am    
Does SELECT count(*) FROM Authentication_Detail WHERE UserName = @username AND password = @password return 1? i.e. Are you sure the record exists in the database?
Member 11279091 18-Feb-15 5:15am    
ya.it exists in database.. when i execute the above query it return 1. while execute the stored procedure it returns o only.
Richard MacCutchan 18-Feb-15 5:00am    
I trust you are hashing your passwords properly and not saving them as clear text.

I have tested it and works fine

CREATE PROCEDURE [dbo].[Proc_Verify_Password]
    @username VARCHAR(20),
    @password varchar(20)
AS
BEGIN
 
 SET NOCOUNT ON
 
SELECT  count(*) FROM Authentication_Detail 
WHERE RTRIM(LTRIM([UserName])) = RTRIM(LTRIM(@username)) 
AND RTRIM(LTRIM([Password])) = RTRIM(LTRIM(@password))

END
 
Share this answer
 
v2
How are u executing the Sql command.As execute nonquery or execute reader?
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900