Click here to Skip to main content
16,016,712 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public override bool ValidateUser(string username, string password)
        {
            using(SqlConnection  conn = new SqlConnection(m_strDBConnection))
            {
                try
                {
                    /* Create command */
                    SqlCommand  command = new SqlCommand("SELECT [Encode],[USERNAME],[PASSWORD]  FROM [dbo].[Users]" + "WHERE [USERNAME]='" + username + "' AND [PASSWORD]='" + password + "'", conn);
                    
                    /* Open connection */
                    conn.Open();
               
                    /* Run query */
                    SqlDataReader  reader = command.ExecuteReader();

                    /* Check if we have something */
                    bool bResult = reader.HasRows;
                    AuthenticateEventArgs e = new AuthenticateEventArgs();
                    
                    /* Close connection */
                    conn.Close();
                    
                    return bResult;
                }
                catch(Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine(ex.Message);
                }
                return false;
            }
        }

It returns like "Your Login Attempt Failed"(Login Failed Message) , when i get fire login. All information are correct for login but it might be problem in web.config. Please Help Me ! :)
Can anybody give me web.config codes for it?
Posted
Updated 11-Nov-11 0:47am
v6
Comments
shashikanth 2011 11-Nov-11 5:14am    
Where is your ConnectionString..?
If you not mentioned about connectionstring then how one can solve the problem,
post your ConnectionString also

Ignoring that that is a massive invitation to an SQL Injection attack, you should not store passwords in clear text.
There is a quick bit of info here: Password Storage: How to do it.[^]

As to your reported problem, it could be anything - you do not give anywhere near enough context for an accurate diagnosis.
 
Share this answer
 
It returns like "Your Login Attemp Failed"
What does? There is nothing in the code above that produces this message so how do you expect people to be able to figure out why?
 
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