CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

Lire res de 2 req dans datagridview C#

Derrick1
Derrick1
Niveau 10
13 novembre 2014 à 21:49:39

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

Bellepomme
Bellepomme
Niveau 10
13 novembre 2014 à 22:19:28

E=M6

Sous forums
  • Aide à l'achat Mac
  • Steam Deck
  • Création de sites web
  • Création de Jeux
  • Linux
  • Programmation
  • Internet
  • Macintosh
  • Hardware