bonjour,

je suis sous W7, VS2010 Ultimate 2010, Firebird 2.5 et la 2.7.7 version of ADO.NET provider de Cincura.

J'ai écris une classe EchoDb qui gère toute la logique accès aux donnés de mon application (connexion , accès aux ps écrit dans Firebird ) et je déclare un objet dans chaque winform nécessaire
Code : Sélectionner tout - Visualiser dans une fenêtre à part
private static EchoDB echoDb = new EchoDB();
Dans une winform l'insertion d'un nouveau champ se fait sans problème en utilisant ce code (les tables du dataset sont créées automatiquement par une ps)

Le code de la ps d'insertion dans EchoDb

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 public FbCommand ExecuterPsInsLaboratoire()
         {
             FbCommand myPs = PreparerPs("P_INS_ETABLISSEMENT_LABO");
             dtaLaboratoire.InsertCommand = myPs;
             FbParameterCollection pc = myPs.Parameters;
             pc.Add("cleLabo", FbDbType.Integer, 0).Direction = ParameterDirection.Output;
             pc.Add("nom", FbDbType.VarChar, 100, "Nom");
             pc.Add("note", FbDbType.VarChar, 300, "Note");
             return myPs;
         }
L'appel de ce code dans la winform


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
private void ValiderClick(object sender, EventArgs e)
        {
            connexion = echoDb.OuvrirConnexion();
 
            if (nbRowLabo == 0)
            {
                try
                {
                    //Insertion laboratoire
                    DataRow row = tblLaboratoire.NewRow();
                    row["Nom"] = txtNom.Text;
                    row["Note"] = txtNote.Text;
                    tblLaboratoire.Rows.Add(row);
                    FbCommand myPsInsLabo = echoDb.ExecuterPsInsLaboratoire();
                    echoDb.DtaLaboratoire.Update(tblLaboratoire.Select("", "", DataViewRowState.Added));
Ca marche très bien

Par contre dans une autre winform
Le code dans EchoDb de préparation de la ps

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
         public FbCommand ExecuterPsInsPersonne() 
         {
             FbCommand myPs = PreparerPs("p_ins_personne_simple");
             dtaPersonne.InsertCommand = myPs;
             FbParameterCollection pc = myPs.Parameters;
             pc.Add("cle", FbDbType.Integer, 0).Direction = ParameterDirection.Output;
             pc.Add("prenom", FbDbType.VarChar, 100, "Prenom");
             pc.Add("nom", FbDbType.VarChar, 100, "Nom");
             pc.Add("date", FbDbType.VarChar, 20, "Nee");
             pc.Add("ville", FbDbType.VarChar, 50, "Ville").IsNullable = true;
             pc.Add("pays", FbDbType.VarChar, 5, "Pays").IsNullable = true;
             pc.Add("genre", FbDbType.VarChar, 5, "Genre").IsNullable = true;
             pc.Add("note", FbDbType.VarChar, 300, "Note").IsNullable = true;
             return myPs;
         }
Le code dans la winform

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
private void BtnValider(object sender, EventArgs e)
        {
            //TRAITEMENT EN RAPPORT AVEC LES CHECKBOX
 
 
            //CREATION ET OUVERTURE CONNECTION
            FbConnection connexion = echoDb.OuvrirConnexion();
 
 
            //TRAITEMENT SI C'EST UNE NOUVELLE FICHE
            if (nbRowPer == 0)
            {
 
 
 
                //Insertion personne
                DataRow row = tblPersonne.NewRow();
                row["prenom"] = txtPrenom.Text;
                row["nom"] = txtNom.Text;
 
                if (txtNeLe.Text.Trim().Length == 0)
                {
                    row["neeLe"] = DBNull.Value;
                }
                else
                {
                    row["neeLe"] = txtNeLe.Text;
                }
 
                 if (txtNeA.Text.Trim().Length == 0)
                {
                    row["ville"] = DBNull.Value;
                }
                else
                {
                    row["ville"] = txtNeA.Text;
                }
 
                 row["pays"] = cbPaysNaissance.SelectedValue;// A VOIR 
                row["genre"] = Genre();
                 row["genre"] = "F";
                 if (txtNote.Text.Trim().Length == 0)
                {
                    row["note"] = DBNull.Value;
                }
                else
                {
                    row["note"] = txtNote.Text;
                }
 
                tblPersonne.Rows.Add(row);
                FbCommand myPsInsPersonne = echoDb.ExecuterPsInsPersonne();
                echoDb.DtaPersonne.Update(tblPersonne.Select("", "", DataViewRowState.Added));
me renvoie toujours argument 'dataType' ne peut pas être null en sachant que les deux premiers paramètres sont toujours non nul

Voici le code de l'erreur.

L'exception System.ArgumentNullException n'a pas été gérée
HResult=-2147467261
Message=L'argument 'dataType' ne peut pas être null.
Nom du paramètre*: dataType
Source=FirebirdSql.Data.FirebirdClient
ParamName=dataType
StackTrace:
à FirebirdSql.Data.FirebirdClient.FbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping) dans C:\Dev\NETProvider\source\FirebirdSql\Data\FirebirdClient\FbDataAdapter.cs:ligne 471
à System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows)
à EchoDef.frmPatiente_4.BtnValider(Object sender, EventArgs e) dans L:\Projet Visual Studio 2010\Projet EchoDef\EchoDef\frmPatiente_4.cs:ligne 311
à System.Windows.Forms.Control.OnClick(EventArgs e)
à System.Windows.Forms.Button.OnClick(EventArgs e)
à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
à System.Windows.Forms.Control.WndProc(Message& m)
à System.Windows.Forms.ButtonBase.WndProc(Message& m)
à System.Windows.Forms.Button.WndProc(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
à System.Windows.Forms.Application.Run(Form mainForm)
à EchoDef.Program.Main() dans L:\Projet Visual Studio 2010\Projet EchoDef\EchoDef\Program.cs:ligne 19
à System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()
InnerException:
J'avoue me casser les dents là......

Merci d'avance pour ce qui pourrait me donner une piste...


Mirmillon