Précédent   Forum du club des développeurs et IT Pro > Dotnet > Accès aux données > ADO.NET
ADO.NET Forum d'entraide sur le développement avec les services d'accès aux données disponibles avec ADO.NET.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 19/07/2012, 19h20   #1
Mirmillon
Membre actif
 
Inscription : octobre 2004
Messages : 146
Détails du profil
Informations personnelles :
Localisation : France, Pas de Calais (Nord Pas de Calais)

Informations forums :
Inscription : octobre 2004
Messages : 146
Points : 155
Points : 155
Par défaut argument 'dataType' ne peut pas être null

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 :
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 :
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 :
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 :
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 :
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.

Citation:
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
__________________
Au royaume des aveugles, les borgnes sont rois.
Mirmillon est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/07/2012, 08h38   #2
Bluedeep
Expert Confirmé Sénior
 
Homme François
Chef de projet NTIC
Inscription : janvier 2007
Messages : 6 544
Détails du profil
Informations personnelles :
Nom : Homme François
Âge : 52
Localisation : France

Informations professionnelles :
Activité : Chef de projet NTIC

Informations forums :
Inscription : janvier 2007
Messages : 6 544
Points : 13 893
Points : 13 893
Bonjour

Si tu ne donnes pas la ligne qui remonte l'exception, je ne vois pas très bien comment on pourrait t'aider.
__________________

Je ne réponds pas aux questions techniques par MP ! Le forum est là pour ça...


Une réponse vous a aidé ? utiliser le bouton

"L’ennui dans ce monde, c’est que les idiots sont sûrs d’eux et les gens sensés pleins de doutes". B. Russel
Bluedeep est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/07/2012, 12h07   #3
Mirmillon
Membre actif
 
Inscription : octobre 2004
Messages : 146
Détails du profil
Informations personnelles :
Localisation : France, Pas de Calais (Nord Pas de Calais)

Informations forums :
Inscription : octobre 2004
Messages : 146
Points : 155
Points : 155
Par défaut Ligne litigieuse

Bonjour,

merci d'avoir pris le temps de me répondre.

voici la ligne litigieuse

Code :
 echoDb.DtaPersonne.Update(tblPersonne.Select("", "", DataViewRowState.Added));
ce que je ne comprends c'est que ce code marche dans un cas et ne marche pas dans l'autre
__________________
Au royaume des aveugles, les borgnes sont rois.
Mirmillon est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 29/07/2012, 17h35   #4
Mirmillon
Membre actif
 
Inscription : octobre 2004
Messages : 146
Détails du profil
Informations personnelles :
Localisation : France, Pas de Calais (Nord Pas de Calais)

Informations forums :
Inscription : octobre 2004
Messages : 146
Points : 155
Points : 155
Il s'agissait en fait d'une discordance de nom entre le nom des champs dans la procédure stockée et le nom du paramètre dans ADO.
__________________
Au royaume des aveugles, les borgnes sont rois.
Mirmillon est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 03h51.


 
 
 
 
Partenaires

Hébergement Web