Merci pour la réponse
Ca ne fonctionne toujours pas, , je suis sure qu'il y a quelque chose de pas correcte que j'ai fait partout sur le Web le refresh et de la même facon dont j'ai écrit
Voici comment je définit la DGV
private BindingSource bindingSource1 = new BindingSource();
1 2 3
| private DataViewManager dsView;
private DataSet ds;
dsView = ds.DefaultViewManager; |
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
private void SetDataObjects()
{
// Create the DataSet
ds = new DataSet();
// Fill the Dataset with Tbl_Facture, map Default Tablename
// "Table" to "Tbl_Facture".
da1 = new OleDbDataAdapter("SELECT * FROM Tb_Factures ORDER BY nFactureID", _Conn);
da1.TableMappings.Add("Table", "Factures");
da1.RowUpdated += new OleDbRowUpdatedEventHandler(da1_OnRowUpdate);
FactureBuilder = new OleDbCommandBuilder(da1);
// da1.Fill(ds);
// Fill the Dataset with LigneFacture , map Default Tablename
da2 = new OleDbDataAdapter("SELECT * FROM Tb_LigneFactures", _Conn);
da2.TableMappings.Add("Table", "LignesFacture");
da2.RowUpdated += new OleDbRowUpdatedEventHandler(da2_OnRowUpdate);
LigneFactureBuilder = new OleDbCommandBuilder(da2);
// da2.Fill(ds);
RunQuery();
// Establish the Relationship "RelFacture_LigneFacture"
// between Facture ---< LignesFacture
System.Data.DataRelation RelFacture_LignesFacture;
System.Data.DataColumn colMaster1;
System.Data.DataColumn colDetail1;
colMaster1 = ds.Tables["Factures"].Columns["nFactureID"];
colDetail1 = ds.Tables["LignesFacture"].Columns["nFactureID"];
if (colDetail1 == null)
{
//S'il n'y a aucune ligne de Facture alors il faut ajouter une nouvelle ligne de Facture
}
RelFacture_LignesFacture = new System.Data.DataRelation("RelFacture_LignesFacture", colMaster1, colDetail1);
ds.Relations.Add(RelFacture_LignesFacture);
}
// Fîll DataGrid with Data
private void RunQuery()
{
try
{
DataColumn[] dcPk = new DataColumn[1];
da1.Fill(ds);
da2.Fill(ds);
// Set Primary Key
dcPk[0] = ds.Tables["Factures"].Columns["nFactureID"];
ds.Tables["Factures"].PrimaryKey = dcPk;
// Set Default Sort
ds.Tables[0].DefaultView.Sort = "nFactureID";
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
Debug.WriteLine(ex.ToString());
}
} |
1 2
| bindingSource1.DataSource = dsView;
tb_LigneCommandeDataGridView.DataSource = bindingSource1; |
Merci beaucoup pour votre aide
Partager