Salut!
j'ai une base de données accès 2007:
Assure(Matricule_unique)
Patient(num_pat,prenom,nom,Adresse,Tel,Qualite,Matricule_unique#)

Je veux insérer un enregistrement à partir d'un formulaire dans ces deux tables. Pour cela j'ai utilisé le code ci dessous mais ça ne marche 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
 
 private void buttonAddpat_Click(object sender, EventArgs e)
        {
 
  /* ---------------------------------------------------'Ajoutre dans la table Assure--------------------------------------------*/
 
            String sinsert0 = "insert into Assure(Matricule_unique) values(?)";         
            OleDbParameter objparm; 
            OleDbParameter objparm1;
            OleDbCommand objinsert = new OleDbCommand();
            OleDbCommand objinsert1 = new OleDbCommand();
 
            objinsert.CommandText = sinsert0;
            objinsert.Connection = bdd.cnx;
 
            rowcollectionpatient = dtpatient.Rows;
            rowpatient = dtpatient.NewRow();
 
            rowpatient["Assure.Matricule_unique"] = comboBoxNumass.Text;
 
            rowpatient["num_pat"] = 1;
            rowpatient["prenom"] = textBoxprenom.Text;
            rowpatient["nom"] = textBoxnom.Text;
            rowpatient["Adresse"] = textBoxadresse.Text;
            rowpatient["Tel"] = textBoxtel.Text;
            rowpatient["Qualite"] = comboBoxQualite.Text;
            rowpatient["Patient.Matricule_unique"] = comboBoxNumass.Text;
 
            rowcollectionpatient.Add(rowpatient);
            dspatient.WriteXml("../../../icone//ds.xml");
 
            objparm = objinsert.Parameters.Add("@Matricule_unique", OleDbType.Char);
            objparm.SourceColumn = "Assure.Matricule_unique";
            objparm.SourceVersion = DataRowVersion.Current;
 
 
           bdd.OpenConnection();
 
            dapatient.InsertCommand = objinsert;
            dapatient.InsertCommand.Connection = bdd.cnx;
            dapatient.Update(dspatient, "tpatient");
            bdd.closeConnection();
/**************************************************************************************************************************/
 
           String sinsert = "insert into Patient(num_pat,prenom,nom,Adresse,Tel,Qualite,Matricule_unique) values(?,?,?,?,?,?,?)";
 
            objinsert1.CommandText = sinsert;
            objinsert1.Connection=bdd.cnx;
 
 
 
            objparm1 = objinsert1.Parameters.Add("@num_pat", OleDbType.Char);
            objparm1.SourceColumn = "num_pat";
            objparm1.SourceVersion = DataRowVersion.Current;
 
            objparm1 = objinsert1.Parameters.Add("@Prenom", OleDbType.Char);
            objparm1.SourceColumn = "Prenom";
            objparm1.SourceVersion = DataRowVersion.Current;
 
            objparm1 = objinsert1.Parameters.Add("@Nom", OleDbType.Char);
            objparm1.SourceColumn = "Nom";
            objparm1.SourceVersion = DataRowVersion.Current;
 
            objparm1 = objinsert1.Parameters.Add("@Adresse", OleDbType.Char);
            objparm1.SourceColumn = "Adresse";
            objparm1.SourceVersion = DataRowVersion.Current;
 
            objparm1 = objinsert1.Parameters.Add("@tel", OleDbType.Char);
            objparm1.SourceColumn = "tel";
            objparm1.SourceVersion = DataRowVersion.Current;
 
            objparm1 = objinsert1.Parameters.Add("@Qualite", OleDbType.Char);
            objparm1.SourceColumn = "Qualite";
            objparm1.SourceVersion = DataRowVersion.Current;
 
          objparm1 = objinsert1.Parameters.Add("@Patient.Matricule_unique", OleDbType.Char);
            objparm1.SourceColumn = "Patient.Matricule_unique";
            objparm1.SourceVersion = DataRowVersion.Current;
 
 
 
                  bdd.OpenConnection();
 
 
 
                      dapatient.InsertCommand = objinsert1;          
                      dapatient.InsertCommand.Connection = bdd.cnx;
                      dapatient.Update(dspatient, "tpatient");
                  bdd.closeConnection();
        }
Merci pour votre aide