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

VB.NET Discussion :

Erreur au niveau de dataset


Sujet :

VB.NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Candidat au Club
    Inscrit en
    Novembre 2007
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Novembre 2007
    Messages : 2
    Par défaut Erreur au niveau de dataset
    bonsoir durant ma programmation du mon projet (emploi du temps scolaire) j'ai rencontré un probleme au niveau de ma Dataset lors du debuguage il m'affiche ce probleme "Une exception non gérée du type 'System.NullReferenceException' s'est produite dans emplois du temps1.exe

    Informations supplémentaires*: La référence d'objet n'est pas définie à une instance d'un objet." au niveau du code suivant "dgdniveau.DataSource = dts.NIVEAU "
    voici le code que j'ai généré
    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
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
     Private Sub professeur_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            dgdniveau.DataSource = dts.NIVEAU
     
            dgdmatiere.DataSource = dts.MATIERE
            dgsalle.DataSource = dts.SALLE
            dgdclasse.DataSource = dts.CLASSE
            lmatiere.DataSource = dts.Tables("MATIERE")
            lmatiere.DisplayMember = "LIBMATIERE"
            lmatiere.ValueMember = "CODEMATIERE"
            lpf.DataSource = dts.Tables("PROF")
            lpf.DisplayMember = "NOMPROF"
            lpf.ValueMember = "CODEPROF"
            lmatiere.DataSource = dts.Tables("MATIERE")
            lmatiere.DisplayMember = "LIBMATIERE"
            lmatiere.ValueMember = "CODEMATIERE"
            Comniveau.DataSource = dts.NIVEAU
            Comniveau.DisplayMember = "LIBNIVEAU"
            Comniveau.ValueMember = "CODENIVEAU"
            CMBNIVEAU.DataSource = dts.NIVEAU
            CMBNIVEAU.DisplayMember = "LIBNIVEAU"
            CMBNIVEAU.ValueMember = "CODENIVEAU"
            retablir(Me.gemploi)
     
        End Sub
     
        Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
     
            'If c2.verifier(GRBPROF) = True Then
            '    s2.ajouterEnregistrement(GRBPROF, dts.PROF)
            '    Dim dr As DataRow
            '    For i As Integer = 0 To lm1.Items.Count - 1
            '        If lm1.GetSelected(i) = True Then
            '            dr = dts.PEUTENSEIGNER.NewRow
            '            dr("CODEPROF") = TXTCODEPROF.Text
            '            dr("CODEMATIERE") = lm1.SelectedValue.ToString
            '        End If
            '    Next
            '    Try
            '        dts.Tables("PEUTENSEIGNER").Rows.Add(dr)
            '    Catch ex As Exception
            '    End Try
     
            '    valider_dispo(Me.gemploi, TXTCODEPROF.Text)
            'End If
            '*****************krim
     
            TXTCODEPROF.Text = nouveau(dts.PROF, "CODEPROF")
            If c2.verifier(Me) = True Then
                If s2.ajouterEnregistrement(Me, dts.PROF) = True Then
                    valider_dispoprof(TXTCODEPROF.Text, Me.gemploi)
                    valider_matiere_prof(TXTCODEPROF.Text, lmatiere)
                    vider_champs(Me.TXTCODEPROF, Me.TXTNBREHEUREMAX, Me.TXTNOMPROF)
                    maj()
                    retablir_dispo_prof(Me.gemploi)
                    retablir_ckl(lmatiere)
                End If
            End If
            TXTCODEPROF.Text = nouveau(dts.PROF, "CODEPROF")
     
     
     
        End Sub
     
     
     
     
        Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
            'If c2.verifier(GRBPROF) = True Then
            '    s2.ModifierEnregistrement(GRBPROF, dts.PROF, "CODEPROF")
     
            'End If
            '************************krim
            If c2.verifier(GRBPROF) = True Then
                s2.ModifierEnregistrement(GRBPROF, dts.PROF, "CODEPROF")
                valider_dispoprof(TXTCODEPROF.Text, Me.gemploi)
                valider_matiere_prof(TXTCODEPROF.Text, lmatiere)
                maj()
            End If
        End Sub
     
        Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
            'If TXTCODEPROF.Text <> "" Then
            '    s2.supprimerenreg(GRBPROF, dts.PROF, "CODEPROF")
            'End If
            'supprimer
            ''''If TXTCODEPROF.Text <> "" Then
            ''''    Call suppression("PROF", CType(TXTCODEPROF.Text, Integer))
     
            ''''End If
     
            '*******************************krim
            If c2.verifier(GRBPROF) = True Then
                s2.supprimerenreg(GRBPROF, dts.PROF, "CODEPROF")
                vider_champs(Me.TXTCODEPROF, Me.TXTNBREHEUREMAX, Me.TXTNOMPROF)
                majsup()
                variables.retablir_dispo_prof(Me.gemploi)
            End If
        End Sub
     
     
        Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
            'If TXTCODEPROF.Text <> "" Then
            '    s2.rechercherenreg(GRBPROF, dts.PROF, "CODEPROF")
     
            '    ''''
            'End If
            'affichage
            For Each DR As DataRow In dts.PROF.Rows
                If DR(0) = TXTCODEPROF.Text Then
                    Try
                        TXTCODEPROF.Text = DR(0)
                        TXTNOMPROF.Text = DR(1)
                        TXTNBREHEUREMAX.Text = DR(2)
                    Catch ex As Exception
     
                    End Try
     
                End If
            Next
        End Sub
     
        '''MATIERE
     
        Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
            'If TXTCODEMATIERE.Text <> "" Then
            '    s2.rechercherenreg(GRBMATIERE, dts.MATIERE, "CODEMATIERE")
            'End If
            For Each DR As DataRow In dts.MATIERE.Rows
                If DR(0) = TXTCODEMATIERE.Text Then
                    Try
                        TXTCODEMATIERE.Text = DR(0)
                        txtLIBMATIERE.Text = DR(1)
                        txtTYPEMATIERE.Text = DR(2)
                    Catch ex As Exception
     
                    End Try
     
                End If
            Next
     
        End Sub
        'ajouter
     
        Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
            If c2.verifier(GRBMATIERE) = True Then
                s2.ajouterEnregistrement(GRBMATIERE, dts.MATIERE)
            End If
        End Sub
        'modifier
     
        Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
            If c2.verifier(GRBMATIERE) = True Then
                s2.ModifierEnregistrement(GRBMATIERE, dts.MATIERE, "CODEMATIERE")
            End If
        End Sub
        'supprimer
        Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
            'If TXTCODEMATIERE.Text <> "" Then
            '    s2.supprimerenreg(GRBMATIERE, dts.MATIERE, "CODEMATIERE")
            'End If
            If TXTCODEMATIERE.Text <> "" Then
                Call suppression("MATIERE", CType(TXTCODEMATIERE.Text, Integer))
     
            End If
        End Sub
        ''''''''''''''''''''''NIVEAU
        Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button20.Click
            'If TXTCODENIVEAU.Text <> "" Then
            '    s2.rechercherenreg(GRBNIVEAU, dts.NIVEAU, "CODENIVEAU")
            'End If
            'affichage
            For Each DR As DataRow In dts.NIVEAU.Rows
                If DR(0) = TXTCODENIVEAU.Text Then
                    Try
                        TXTCODENIVEAU.Text = DR(0)
                        TXTLIBNIVEAU.Text = DR(1)
     
                    Catch ex As Exception
                    End Try
     
                End If
            Next
        End Sub
        'ajouter
     
        Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button19.Click
            If c2.verifier(GRBNIVEAU) = True Then
                s2.ajouterEnregistrement(GRBNIVEAU, dts.NIVEAU)
            End If
        End Sub
        'modifier
     
        Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
            If c2.verifier(GRBNIVEAU) = True Then
                s2.ModifierEnregistrement(GRBNIVEAU, dts.NIVEAU, "CODENIVEAU")
            End If
        End Sub
        'supprimer
     
        Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
            'If TXTCODENIVEAU.Text <> "" Then
            '    s2.supprimerenreg(GRBNIVEAU, dts.NIVEAU, "CODENIVEAU")
            'End If
            If TXTCODENIVEAU.Text <> "" Then
                Call suppression("NIVEAU", CType(TXTCODENIVEAU.Text, Integer))
     
            End If
        End Sub
     
        Private Sub lbp1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbp30.Click, lbp25.Click, lbp20.Click, lbp15.Click, lbp10.Click, lbp5.Click, lbp29.Click, lbp28.Click, lbp27.Click, lbp24.Click, lbp23.Click, lbp22.Click, lbp26.Click, lbp21.Click, lbp19.Click, lbp18.Click, lbp17.Click, lbp14.Click, lbp13.Click, lbp12.Click, lbp16.Click, lbp11.Click, lbp9.Click, lbp8.Click, lbp7.Click, lbp4.Click, lbp3.Click, lbp2.Click, lbp6.Click, lbp1.Click
            couleur(sender)
        End Sub
     
        ''''''''''''''''''''''CLASSE
        'ajouter
     
        Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
            If c2.verifier(grbclasse) = True Then
                s2.ajouterEnregistrement(grbclasse, dts.CLASSE)
                valider_dispo(Me.gemploi, txtCODECLASSE.Text)
            End If
            'For Each DR As DataRow In dts.NIVEAU.Rows
            '    If txtCODECLASSE.Text = DR(0) Then
            '        Try
            '            DR(0) = txtCODECLASSE.Text
            '            DR(1) = Comniveau.Text
            '            DR(2) = TXTSPECIALITE.Text
            '            DR(3) = TXTNBRHEURE.Text
            '        Catch ex As Exception
            '        End Try
     
            '    End If
            'Next
            'dts.CLASSE.Add(DR).rows()
        End Sub
        'modifier
     
        Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
            If c2.verifier(grbclasse) = True Then
                s2.ModifierEnregistrement(grbclasse, dts.CLASSE, "CODECLASSE")
            End If
        End Sub
     
        Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
            'If txtCODECLASSE.Text <> "" Then
            '    s2.rechercherenreg(grbclasse, dts.CLASSE, "CODECLASSE")
            'End If
            'affichage
            For Each DR As DataRow In dts.NIVEAU.Rows
                If DR(0) = txtCODECLASSE.Text Then
                    Try
                        txtCODECLASSE.Text = DR(0)
                        Comniveau.Text = DR(1)
                        TXTSPECIALITE.Text = DR(2)
                        TXTNBRHEURE.Text = DR(3)
                    Catch ex As Exception
                    End Try
     
                End If
            Next
        End Sub
        'supprimer
     
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            'If txtCODECLASSE.Text <> "" Then
            '    s2.supprimerenreg(grbclasse, dts.CLASSE, "CODECLASSE")
            'End If
            If txtCODECLASSE.Text <> "" Then
                Call suppression("CLASSE", CType(txtCODECLASSE.Text, Integer))
     
            End If
        End Sub
        ''''''''''''''''''''SALLE
        'ajouter
     
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            If c2.verifier(GRBSALLE) = True Then
                s2.ajouterEnregistrement(GRBSALLE, dts.SALLE)
                'valider_dispo(Me.gemploi, TXTCODESALLE.Text)
            End If
        End Sub
        'modifier
     
        Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            If c2.verifier(GRBSALLE) = True Then
                s2.ModifierEnregistrement(GRBSALLE, dts.SALLE, "CODESALLE")
            End If
        End Sub
        'supprimer
     
        Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
            '    If TXTCODESALLE.Text <> "" Then
            '        s2.supprimerenreg(GRBSALLE, dts.SALLE, "CODESALLE")
            '    End If
            If TXTCODESALLE.Text <> "" Then
                Call suppression("SALLE", CType(TXTCODESALLE.Text, Integer))
            End If
        End Sub
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            'If TXTCODESALLE.Text <> "" Then
            '    s2.rechercherenreg(GRBSALLE, dts.SALLE, "CODESALLE")
            'End If
            For Each DR As DataRow In dts.SALLE.Rows
                If DR(0) = TXTCODESALLE.Text Then
                    Try
                        TXTCODESALLE.Text = DR(0)
                        TXTLIBSALLE.Text = DR(1)
                        TXTTYPESALLE.Text = DR(2)
                    Catch ex As Exception
                    End Try
                End If
            Next
        End Sub
     
     
    End Class
    sachant que je travail avec vb.net 2003 avec une base de donnée access 2000 et merci

  2. #2
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    127
    Détails du profil
    Informations personnelles :
    Âge : 38
    Localisation : France, Nord (Nord Pas de Calais)

    Informations forums :
    Inscription : Mars 2007
    Messages : 127
    Par défaut
    Tout le code comme ça c'est un peu barbare !!
    Ou est la définition de s2? qu'est-ce que c'est que cet aimal, on dirait que c'est ton objet de ta classe d'accès aux données.
    Fin bref le truc c'est que au load tu commence direct à utiliser dts mais je ne vois null part où tu le déclare ni où tu le charge, et il me semble que t'on erreur ressemblerais bien à un dataset vide!!, donc non chargé.

    EDIT: dim dts as new data.dataset ?

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

    Informations professionnelles :
    Activité : Chef de projet NTIC

    Informations forums :
    Inscription : Janvier 2007
    Messages : 6 604
    Par défaut
    Il y a trop de commentaires dans ce code, on y voit rien

  4. #4
    Candidat au Club
    Inscrit en
    Novembre 2007
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Novembre 2007
    Messages : 2
    Par défaut le probleme est resolu
    merci de votre reponse a ce sujet j'ai bien saisie mon erreur je viens de la rectifier c gentil de votre part .

  5. #5
    Rédacteur
    Avatar de SaumonAgile
    Homme Profil pro
    Team leader
    Inscrit en
    Avril 2007
    Messages
    4 028
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Team leader
    Secteur : Conseil

    Informations forums :
    Inscription : Avril 2007
    Messages : 4 028
    Par défaut
    Citation Envoyé par fromhell Voir le message
    merci de votre reponse a ce sujet j'ai bien saisie mon erreur je viens de la rectifier c gentil de votre part .
    Alors merci de marquer le sujet comme résolu.
    Besoin d'un MessageBox amélioré ? InformationBox pour .NET 1.1, 2.0, 3.0, 3.5, 4.0 sous license Apache 2.0.

    Bonnes pratiques pour les accès aux données
    Débogage efficace en .NET
    LINQ to Objects : l'envers du décor

    Mon profil LinkedIn - MCT - MCPD WinForms - MCTS Applications Distribuées - MCTS WCF - MCTS WCF 4.0 - MCTS SQL Server 2008, Database Development - Mon blog - Twitter

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

Discussions similaires

  1. [.NET]Erreur de connexion (OleDbAdapter,dataSet)
    Par fab3131 dans le forum MFC
    Réponses: 2
    Dernier message: 28/05/2006, 12h03
  2. [phpBB] Erreur au niveau de la base suite à mise à jour
    Par Goundy dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 6
    Dernier message: 05/03/2006, 14h50
  3. [Delphi7 + FB1.5.3] Erreur de rafraichissement du dataset.
    Par Andry dans le forum Bases de données
    Réponses: 5
    Dernier message: 03/03/2006, 15h43
  4. [EJB] Erreur au niveau de la récuperation du home
    Par ujoodha dans le forum Java EE
    Réponses: 3
    Dernier message: 05/10/2005, 13h50
  5. [C#]Erreur pour remplir mon dataset
    Par liliprog dans le forum Windows Forms
    Réponses: 16
    Dernier message: 15/07/2005, 19h03

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