Salut à tous, je travaille sur un projet de gestion d'une petite base de données ms access, mon problème est le suivant j'ai créé un DataSet tmpDataSet dans lequel je charge une seule table et un OleDbAdapter dbAdpter pour enregistrer les modifications, les insertions marchent à merveille mais les mises à jour pas du tout lors de l'appel de la fonction Update du OleDbAdapter, ça fait deux jours que je cherche le problème mais je ne trouve pas !!
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
38
39
40
41
42
43
44
45
46
 
void UpdateFactureControlLoad(object sender, EventArgs e)
        {
            tmpDataSet = new DataSet();
 
            DbAdapter = new OleDbDataAdapter("select IdRef,IdFac,Ref,Des,Qua,Pri,Tot,Sol from Facture", DBUtil.StringConnection);
 
            DbAdapter.UpdateCommand = new OleDbCommand(@"update Facture set Ref=@Ref and Des=@Des and Qua=@Qua and Pri=@Pri and Sol=@Sol and Tot=10" +
                " where IdFac=@IdFac and IdRef=@IdRef", new OleDbConnection(DBUtil.StringConnection));
 
            OleDbParameter param;
 
            param = DbAdapter.UpdateCommand.Parameters.Add("@Ref", OleDbType.VarChar, 0, "Ref");
            param.SourceVersion = DataRowVersion.Current;
            param = DbAdapter.UpdateCommand.Parameters.Add("@Des", OleDbType.VarChar, 0, "Des");
            param.SourceVersion = DataRowVersion.Current;
            param = DbAdapter.UpdateCommand.Parameters.Add("@Qua", OleDbType.Numeric, 0, "Qua");
            param.SourceVersion = DataRowVersion.Current;
            param = DbAdapter.UpdateCommand.Parameters.Add("@Pri", OleDbType.Numeric, 0, "Pri");
            param.SourceVersion = DataRowVersion.Current;
            param = DbAdapter.UpdateCommand.Parameters.Add("@Sol", OleDbType.Numeric, 0, "Sol");
            param.SourceVersion = DataRowVersion.Current;
 
            param = DbAdapter.UpdateCommand.Parameters.Add("@IdFac", OleDbType.Numeric, 0, "IdFac");
            param.SourceVersion = DataRowVersion.Original;
            param = DbAdapter.UpdateCommand.Parameters.Add("@IdRef", OleDbType.Numeric, 0, "IdRef");
            param.SourceVersion = DataRowVersion.Original;
 
 
            DbAdapter.InsertCommand = new OleDbCommand(@"insert into Facture(IdFac,Ref,Des,Qua,Pri,Tot,Sol) values(1,@Ref,@Des,@Qua,@Pri,@Tot,@Sol)", new OleDbConnection(DBUtil.StringConnection));
            DbAdapter.InsertCommand.Parameters.Add("@Ref", OleDbType.VarChar, 0, "Ref");
            DbAdapter.InsertCommand.Parameters.Add("@Des", OleDbType.VarChar, 0, "Des");
            DbAdapter.InsertCommand.Parameters.Add("@Qua", OleDbType.Numeric, 0, "Qua");
            DbAdapter.InsertCommand.Parameters.Add("@Pri", OleDbType.Numeric, 0, "Pri");
            DbAdapter.InsertCommand.Parameters.Add("@Pri", OleDbType.Numeric, 0, "Tot");
            DbAdapter.InsertCommand.Parameters.Add("@Sol", OleDbType.Numeric, 0, "Sol");
 
            DbAdapter.Fill(tmpDataSet, "tmpFacture");
 
            this.tmpDataSet.Tables["tmpFacture"].Columns["IdFac"].ColumnMapping = MappingType.Hidden;
            this.tmpDataSet.Tables["tmpFacture"].Columns["IdRef"].ColumnMapping = MappingType.Hidden;
 
            this.dataGridView1.DataSource = tmpDataSet;
            this.dataGridView1.DataMember = @"tmpFacture";
 
        }