Bonsoir, je remplis mon datagridview avec cette méthode
public static void remplirdatagridview(DataGridView tab)
{
MySqlCommand objreqsql = FormAccueil.objCnx.CreateCommand();
objreqsql.CommandText = "SELECT * FROM x";
MySqlDataReader objresultat = objreqsql.ExecuteReader();
while (objresultat.Read())
{
tab.Rows.Add(objresultat.GetValue(0), objresultat.GetValue(1), objresultat.GetValue(2), objresultat.GetValue(3), objresultat.GetValue(4), objresultat.GetValue(5));
}
objreqsql.ExecuteNonQuery();
objresultat.Close();
}
Le problème est que je souhaiterais la modifier pour afficher aussi dans le datagridview le libellé du lieu, j'ai une clé étrangère x.idLieu = y.idLieu
Donc j'avais tenté un
MySqlCommand objreqsql = FormAccueil.objCnx.CreateCommand();
objreqsql.CommandText = "SELECT * FROM x";
MySqlDataReader objresultat = objreqsql.ExecuteReader();
MySqlCommand objreqsql2 = FormAccueil.objCnx.CreateCommand();
objreqsql2.CommandText = "SELECT libelleLieu FROM y";
MySqlDataReader objresultat2 = objreqsql2.ExecuteReader();
while (objresultat.Read() && objresultat2.Read())
{
tab.Rows.Add(objresultat.GetValue(0), objresultat.GetValue(1), objresultat.GetValue(2), objresultat.GetValue(3), objresultat.GetValue(4), objresultat.GetValue(5), objresultat2.GetValue(1));
}
objreqsql.ExecuteNonQuery();
objreqsql2.ExecuteNonQuery();
objresultat.Close();
objresultat2.Close();
}
Mais rien à faire ça ne fonctionne pas, j'ai bien essayé de chercher quelques tutos mais pas trouvé grand chose. Merci de votre aide