Bonjour,

Lorsque je fais des modifications dans le formulaire en C#, je ne suis pas capable de sauvegarder les modifications, il n'y aucune modification effectué sur ma BD access:

voici mon code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
 
 private void SaveChanges()
        {
           bool _bFormsValidate = Validate();
           if (_bFormsValidate)
           {
               OleDbCommandBuilder cb = new OleDbCommandBuilder(_daLigneCommande);
 
               _daLigneCommande.Update(_dsLigneCommande.Tables[0]);
               _dsLigneCommande.AcceptChanges();
 
            // Update an existing record in the DataSet
               DataRow drFound = _dsLigneCommande.Tables[0].Rows.Find(txtLigneCommande.Text);
 
            if (drFound == null)
                {
                    MessageBox.Show("No PK matches " + txtLigneCommande.Text);
                }
                else
                {
                    drFound.BeginEdit();
                     drFound["csOrderNum"] = this.txtOrderNum.Text; ;
                    drFound["csNomClient"] = this.txtNomClient.Text;
                    drFound["csLineID"] = this.txtLine.Text;
                    drFound["nCouleurAID"] = this.cboCouleurA.SelectedValue ;
                    drFound["nCouleurBID"] = this.cboCouleurB.SelectedValue;
                    drFound["nCouleurCID"] = this.cboCouleurC.SelectedValue;
                    drFound["nCouleurDID"] = this.cboCouleurD.SelectedValue;
                     drFound.EndEdit ();
                    _daLigneCommande.TableMappings.Add("tb_LigneCommandes", _dsLigneCommande.DataSetName);
                    //Update the record even in the database
                    _daLigneCommande.Update(_dsLigneCommande.GetChanges(), "tb_LigneCommandes");
                    //Align in-memory data with the data source ones
                    _dsLigneCommande.AcceptChanges();
                }
           }
Merci