Click here to Skip to main content
15,909,091 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I writes a Stored Procedure to check username and password that as follows:

SQL
create procedure Chk_UnamePWD
@UName varchar,@PWD varchar
as
begin
    select count(*) from tblCustomerVendorInfo where CVUserName=@UName and CVPassword=@PWD;
end

exec Chk_UnamePWD 'BBB','BBB'


Eventhough the given username and password is correct Stored Procedure is returns only 0(Zero).

Please advise me to solve this.

Thanks

K Uday
Posted
Comments
barneyman 18-Aug-11 6:00am    
whichever solution you go with, I'd advise you not to store the actual password, store an MD5 of the salted password

try to find Out in the following Way

SQL
Declare @Result int
if exists(select * from product  where name = 'product1')
begin
set @Result=1
select @result
end

else
begin
set @Result=0
select @Result
end
 
Share this answer
 
test the query with the next partial queries:
1: select count(*) from tblCustomerVendorInfo;
do you get all values from the table?

2: select count(*) from tblCustomerVendorInfo where CVUserName=@UName
do you get the single user?

in this wau you can see if the basic query or the username is wrong. If both cases return the expected values than the problem might be your password part.
what of you check select * on the second test query. Do you see the details and does the given password matches the one in the database?
 
Share this answer
 
Comments
udaysimha 18-Aug-11 7:28am    
Hi,
I tried all what your suggested there i getting correct result, but in SP only i did`t get correct result.
Try using select count(*) from tblCustomerVendorInfo where CVUserName='BBB' and CVPassword='BBB'; in management studio and see if it returns any row. May be there are some leading or trailing spaces in the value.
 
Share this answer
 

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