mysql check if password is correct c# code example

Example: mysql check if password is correct c#

private bool IsValidUser(string userName, string passWord)

{
bool loginSuccessful = false;
 string sql = "SELECT* FROM  Login WHERE Username=@UserName AND [Password]=@Password'";

SqlCommand sqlCommand= new SqlCommand(sql, con);
sqlCommand.Parameters.Add(new SqlParameter("Name", userName));
sqlCommand.Parameters.Add(new SqlParameter("[Password]", passWord));
SqlDataReader rdr = mySQL.ExecuteReader();

if (rdr.HasrRows()) 
   loginSuccessful = true;

return loginSuccessful ;
}

Tags:

Misc Example