plusieurs datatable dans un datagridview
Bonjour,
J'ai une petite question.
Est-ce qu'on peut avoir plusieurs tables dans un datagridview?
J'ai une table joueur et arbitre.
Sois je crée deux datagridview une pour chaque table.
Ou alors je peux afficher la tables que je veux dans le datagridview?
Pour l'instant je fais ça:
Code:
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 34 35
| connectionStr = "...";
MySqlConnection Connection = new MySqlConnection(connectionStr);
try
{
dt = new DataTable();
// Ici, on ouvre la connexion au serveur
Connection.Open();
myDa = new MySqlDataAdapter();
MySqlCommandBuilder myCommanBuild = new MySqlCommandBuilder(myDa);
// On associe cette requête à la propriété SelectCommand du MySqlDataAdapter
//MySQLCmd represente sois SELECT * FROM JOUEUR
// ou SELECT * FROM ARBITRE
myDa.SelectCommand = new MySqlCommand(MySQLCmd, Connection);
myDa.Fill(dt);
BindingSource bindingSource = new BindingSource();
bindingSource.DataSource = dt;
dgvJoueur.DataSource = bindingSource;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
// Application.Exit();
}
if (Connection.State == ConnectionState.Open)
{
Connection.Close();
} |
Cordialement.