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 29 30 31 32 33
|
MySqlConnection connection = new MySqlConnection("SERVER=localhost; DATABASE=travellocked; UID=root; PASSWORD="); // Connection avec la base de données PHP MYAdmin
bool connection_statut = false;
var query = " SELECT * FROM tb_agent WHERE Identifiant= " + "'" + TextBox_Home_ID.Text + "'" + " AND Motdepasse=" + "'" + TextBox_Home_MDP.Text + " ' ";
MySqlCommand cmd = new MySqlCommand(query, connection);
int result = (int)cmd.ExecuteScalar(); // L'ERREUR SE PLACE ICI MEME //
MessageBox.Show(result.ToString());
if (result > 0 )
{
try //Le programme essaye de se connecté pour retourner une valeur booléenne à l'état de connection.
{
connection.Open();
connection_statut = true;
MessageBox.Show("CONNEXION REUSSIE");
}
catch (MySqlException co) //Le cas d'un échec de connection
{
connection.Close();
MessageBox.Show(co.ToString());
MessageBox.Show("Connexion échouée");
connection_statut = false;
}
} |