IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ADO.NET Discussion :

argument 'dataType' ne peut pas être null


Sujet :

ADO.NET

  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    147
    Détails du profil
    Informations personnelles :
    Localisation : France, Pas de Calais (Nord Pas de Calais)

    Informations forums :
    Inscription : Octobre 2004
    Messages : 147
    Points : 184
    Points
    184
    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 : 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
    Au royaume des aveugles, les borgnes sont rois.

  2. #2
    Inactif  
    Homme Profil pro
    Chef de projet NTIC
    Inscrit en
    Janvier 2007
    Messages
    6 604
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France

    Informations professionnelles :
    Activité : Chef de projet NTIC

    Informations forums :
    Inscription : Janvier 2007
    Messages : 6 604
    Points : 13 314
    Points
    13 314
    Par défaut
    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

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    147
    Détails du profil
    Informations personnelles :
    Localisation : France, Pas de Calais (Nord Pas de Calais)

    Informations forums :
    Inscription : Octobre 2004
    Messages : 147
    Points : 184
    Points
    184
    Par défaut Ligne litigieuse
    Bonjour,

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

    voici la ligne litigieuse

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     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.

  4. #4
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    147
    Détails du profil
    Informations personnelles :
    Localisation : France, Pas de Calais (Nord Pas de Calais)

    Informations forums :
    Inscription : Octobre 2004
    Messages : 147
    Points : 184
    Points
    184
    Par défaut
    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.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. au moins l'un des arguments ne peut pas être marshalé
    Par thierry007 dans le forum Windows Forms
    Réponses: 3
    Dernier message: 07/05/2015, 13h16
  2. Réponses: 10
    Dernier message: 21/10/2013, 20h19
  3. [Débutant] La valeur ne peut pas être null. Nom du paramètre : objectType
    Par ozthewizard dans le forum VB.NET
    Réponses: 7
    Dernier message: 30/09/2011, 09h06
  4. Réponses: 6
    Dernier message: 29/12/2010, 01h16
  5. Réponses: 3
    Dernier message: 18/08/2010, 15h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo