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
| private void AlimenterDataGrid(object sender, EventArgs e)
{
SqlConnection con_listeTache = new SqlConnection("Data Source=CHNET\\SQLEXPRESS;Initial Catalog=test;User ID=sa;Password=*");
DataSet ds = new DataSet();
SqlDataAdapter sda_principal = new SqlDataAdapter("select Id_tache,demande_tache,date_tache as Date,intervenant_tache as Intervenant,detail_tache as Detail from tblDemandeTache", con_listeTache);
sda_principal.Fill(ds, "tblTache");
SqlDataAdapter sda_secondaire = new SqlDataAdapter("select Id_tache,fichier_document from tblDemandeTacheDocument", con_listeTache);
sda_secondaire.Fill(ds, "tblDocument");
DataRelation relation = new DataRelation("TacheDocument",
ds.Tables["tblTache"].Columns["Id_tache"],
ds.Tables["tblDocument"].Columns["Id_tache"]);
ds.Relations.Add(relation);
tacheBindingSource.DataSource = ds;
tacheBindingSource.DataMember = "tblTache";
documentBindingSource.DataSource = tacheBindingSource;
documentBindingSource.DataMember = "TacheDocument";
dataGridView1.DataSource = tacheBindingSource;
dataGridView2.DataSource = documentBindingSource;
} |
Partager