La référence d'objet n'est pas définie à une instance d'un objet

Résolu/Fermé
dalydooo Messages postés 57 Date d'inscription dimanche 19 avril 2015 Statut Membre Dernière intervention 4 mars 2019 - Modifié le 4 sept. 2017 à 13:46
Whismeril Messages postés 19022 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 17 avril 2024 - 4 sept. 2017 à 16:12
Bonjour,
Est ce que vous pouvez m'aider sur cette erreur ..
tous les condition se fonctionne sauf
quand je met le mdp incorrect il m'affiche cette erreur
https://img-19.ccm2.net/Hzy_cBOw0g98ecB6T6itnU-S9HQ=/a1770ca188e54ac5a1dc697f5ed8ce37/ccm-ugc/Sans_titre.png

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;


namespace WebApplication5
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Bu_Log_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DaliConnectionString"].ConnectionString);
            conn.Open();
            string checkuser = "select count(*) from Authentification where Email ='" + txtemail2.Text + "'";
            SqlCommand com = new SqlCommand(checkuser, conn);
            int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
            conn.Close();
            if (temp == 1)
            {
                conn.Open();
                string checkPasswordQuery = "Select Password from Authentification where Email ='" + txtemail2.Text + "'";
                SqlCommand passComm = new SqlCommand(checkPasswordQuery, conn);
                string Password = passComm.ExecuteScalar().ToString();
                conn.Close();

                //---------------------------------------
                conn.Open();
                string checkStatutQuery = "Select StatutID from Authentification where Email ='" + txtemail2.Text + "' and Password ='" + txtmdp2.Text + "'";
                SqlCommand StatutComm = new SqlCommand(checkStatutQuery, conn);
                string StatutID = StatutComm.ExecuteScalar().ToString();
                conn.Close();


                if  (StatutID=="1")
                {
                    Session["New"] = txtemail2.Text;
                    Response.Redirect("index.html");
                    
                }
                else if (StatutID == "3")
                {
                    lb2.Text = "Vous etes en attente";

                }
                else if (StatutID == "2")
                {
                    lb2.Text = "Votre compte est inactif";

                }
                
                else
                    {
                    lb2.Text = "Password is not correct" ;

                     }
            }
            else
            {
                    lb2.Text = "Email is not correct";
            }
           
              
          

        }
        
    }
}


merci d'avance

EDIT : Ajout des balises de code (la coloration syntaxique).
Explications disponibles ici : ICI

Merci d'y penser dans tes prochains messages.

2 réponses

Whismeril Messages postés 19022 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 17 avril 2024 928
4 sept. 2017 à 16:12
De rien, pense à mettre le sujet résolu si cela te convient.
Il y a un lien dédié sous le titre de la discussion
3