1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| private Boolean CheckStatus(String identifier, String password)
{
using (MySqlConnection connection = new MySqlConnection(connectionString))
{
using (MySqlCommand command = new MySqlCommand())
{
command.Connection = connection;
command.Parameters.Add("@Identifier", SqlDbType.VarChar).Value = identifier;
command.Parameters.Add("@Password", SqlDbType.VarChar).Value = password;
command.CommandText = "SELECT * FROM tb_agent WHERE Identifiant=@Identifier AND Motdepasse=@Password";
try
{
connection.Open();
return (command.ExecuteScalar() != null);
}
catch (Exception ex)
{
if (ex is InvalidOperationException || ex is SqlException)
{
return false;
}
throw;
}
}
}
} |