Bonjour,
J'ai une NullReferenceException que je ne comprend pas au moment de créer un objet voici l'intégralité de mon code de la page.

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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.Common;
using System.Text.RegularExpressions;
using UdeM.Telephonie;
 
namespace GestionBottinWeb
{
    public partial class ModifierInfos : System.Web.UI.Page
    {
        private String chaineConnexion = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\sources\Telephonie\UdeM.Telephonie\Telephonie.mdf;Integrated Security=True;User Instance=True";
        private String chaineConnexion2 = @"Data Source=prtdev3;Initial Catalog=udembd;Integrated Security = SSPI";
        private DbProviderFactory dbProviderFactory = SqlClientFactory.Instance;
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                FabriqueCarteAppel carte = new FabriqueCarteAppel(dbProviderFactory, chaineConnexion);
                FabriqueCodeInterurbain code = new FabriqueCodeInterurbain(dbProviderFactory, chaineConnexion);
                FabriquePersonne personne = new FabriquePersonne(dbProviderFactory, chaineConnexion2);
 
                if (Request.QueryString["PersonneNo"] != null)
                {
                    int PersonneNo = int.Parse(Request.QueryString["PersonneNo"]);
                    IPersonne pers = personne.Lire(PersonneNo);
 
                    if (personne != null)
                    {
                        LabelPrenomDuContactAModifier.Text = pers.Pren;
                        LabelNomDuContactAModifier.Text = pers.Nomf;
                        LabelMatricule.Text = Convert.ToString(pers.PersonneNo);
                        DropDownListModifCarteAppel.SelectedValue = Request.QueryString["NoCarte"];
                        DropDownListModifCodeInter.SelectedValue = Request.QueryString["NoCode"];
                    }
                }
            }
        }
 
        protected void ValideModif_Click(object sender, EventArgs e)
        {
            SqlConnection oConnection = new SqlConnection(chaineConnexion);
            oConnection.Open();
 
            FabriquePersonne personne = new FabriquePersonne(dbProviderFactory, chaineConnexion2);
 
            FabriqueCarteAppel carte = new FabriqueCarteAppel(dbProviderFactory, chaineConnexion);
            String requeteSQLcarte = "SELECT personne_no FROM carte_appel WHERE carte_appel_no=" + DropDownListModifCarteAppel.SelectedValue;
            SqlCommand oCommandCarte = new SqlCommand(requeteSQLcarte, oConnection);
            String requeteSQLcarte2 = "SELECT idcarte_appel FROM carte_appel WHERE carte_appel_no=" + DropDownListModifCarteAppel.SelectedValue;
            SqlCommand oCommandCarte2 = new SqlCommand(requeteSQLcarte2, oConnection);
 
            if (Convert.ToString(oCommandCarte.ExecuteScalar()).Equals(""))
            {
                if (Request.QueryString["PersonneNo"] != null)
                {
                    int PersonneNo = int.Parse(Request.QueryString["PersonneNo"]);
                    IPersonne pers = personne.Lire(PersonneNo);
                    if (personne != null)
                    {
                        int idcarte = (int)oCommandCarte2.ExecuteScalar();
                        ICarteAppel CarteModifier = new CarteAppel(idcarte, carte.Lire(idcarte).CarteAppelNo, carte.Lire(idcarte).CompteIdCompte, PersonneNo);
                        carte.Modifier(CarteModifier);
                        LabelCommentairesCarte.Text = pers.Pren + " " + pers.Nomf + " a désormais une carte d'appel ayant pour numéro " + carte.Lire(idcarte).CarteAppelNo + ".";
                    }
                }
            }
            else if (Convert.ToString(oCommandCarte.ExecuteScalar()).Equals(Request.QueryString["PersonneNo"]))
            {
                LabelCommentairesCarte.Text = "La carte d'appel n'a pas été changé.";  
            }
            else
            {
                LabelCommentairesCarte.Text = "Ce numéro de carte d'appel est déjà utilisé par une autre personne, si vous confimez cette opération ce numéro vous sera assigné et sera supprimé à cette personne.";
                ConfirmeCarte.Visible = true;
                AnnuleCarte.Visible = true;
            }
 
            FabriqueCodeInterurbain code = new FabriqueCodeInterurbain(dbProviderFactory, chaineConnexion);
            String requeteSQLcode = "SELECT personne_no FROM code_inter WHERE code=" + DropDownListModifCodeInter.SelectedValue;
            SqlCommand oCommandCode = new SqlCommand(requeteSQLcode, oConnection);
 
            if (Convert.ToString(oCommandCode.ExecuteScalar()).Equals(""))
            {
                LabelCommentairesCode.Text = "On modifie.";
            }
            else if (Convert.ToString(oCommandCode.ExecuteScalar()).Equals(Request.QueryString["PersonneNo"]))
            {
                LabelCommentairesCode.Text = "La code interurbain n'a pas été changé.";
            }
            else
            {
 
                LabelCommentairesCode.Text = "Ce numéro de code interurbain est déjà utilisé par une autre personne, si vous confimez cette opération ce numéro vous sera assigné et sera supprimé à cette personne.";
                ConfirmeCode.Visible = true;
                AnnuleCode.Visible = true;
            }
 
            oConnection.Close();
        }
 
        protected void ConfirmeCarte_Click(object sender, EventArgs e)
        {
            ConfirmeCarte.Visible = false;
            AnnuleCarte.Visible = false;
            LabelCommentairesCarte.Text = "On modifie en supprimant la carte de la personne.";
        }
 
        protected void AnnuleCarte_Click(object sender, EventArgs e)
        {
            ConfirmeCarte.Visible = false;
            AnnuleCarte.Visible = false;
        }
 
        protected void ConfirmeCode_Click(object sender, EventArgs e)
        {
            ConfirmeCode.Visible = false;
            AnnuleCode.Visible = false;
            LabelCommentairesCode.Text = "On modifie en supprimant le code de la personne.";
        }
 
        protected void AnnuleCode_Click(object sender, EventArgs e)
        {
            ConfirmeCode.Visible = false;
            AnnuleCode.Visible = false;
        }
 
        protected void Retour_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["PersonneNo"] != null)
            {
                int PersonneNo = int.Parse(Request.QueryString["PersonneNo"]);
                Response.Redirect("Contacts.aspx?PersonneNo=" + PersonneNo);
            }
        }
    }
}
La NullReferenceException se situe à la ligne 69.

Merci de votre aide