I have this very simple method called to check if a user has a correct password. Any help on why it isn't working? This is for Microsoft SQL Server.
public bool UserNameExists()
{
using (SqlConnection con = new SqlConnection("CONNECTION STRING AQUI!"))
{
con.Open();
try
{
using (SqlCommand command = new SqlCommand(string.Format("SELECT * FROM Policia WHERE NumeroPlaca = '{0}' AND Password = '{1}'", Session.Contents["username"], Session.Contents["password"]), con))
{
SqlDataReader reader = command.ExecuteReader();
if (reader.FieldCount > 0)
{
return true;
}
else
{
return false;
}
}
}
catch
{
}
return false;
}
}