Click here to Skip to main content
15,907,906 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Why correct username and password some time make problem while login asp.net c# ?
Posted
Comments
Gitanjali Singh 31-Jan-14 1:58am    
Please post you code.
King Fisher 31-Jan-14 2:34am    
code?
kashif Atiq 31-Jan-14 3:09am    
You should post more details and code so that we can see what is the problem

1 solution

We can't be accurate from that little - we would need better info on your code, and what username / password combinations work and which don't to be specific.

But...

The "Normal" reason for this is pretty simple:

When the code concatenates strings to build an SQL command:
C#
string sql = "SELECT * FROM users WHERE username=" + textBoxUserName.Text + " AND password=" + textboxPassword.Text;

Because any "oddities" in the name or password are passed through to SQL and it tries to understand them and fails. This is a spectacularly silly way to do things, as it also leave you wide open to SQL Injection attack which can damage or destroy your database. For a website to do this with it's login screen is suicidal as you do not even have to know a valid username to delete the DB, much less a valid password as well. Use Parameterized queries and both problems go away - your current one and the SQL Injection.

In addition, anything which stores the password in clear text is a major security risk! See here: Password Storage: How to do it.[^]
 
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