I doing this code for login,
For suppose i am enterd incorrect Email and password getting an error like below
ERROR:Object reference not set to an instance of an object.
string strCon = ConfigurationManager.ConnectionStrings["stgdbConnectionString"].ConnectionString;
string strSelect = "SELECT ClientId FROM CLIENT WHERE Email = @Email AND Password = @Password";
//string strSelect1 = "select ClientId from CLIENT where Email = @Email AND Password = @Password";
SqlConnection con = new SqlConnection(strCon);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = strSelect;
SqlParameter email = new SqlParameter("@Email", SqlDbType.VarChar, 50);
email.Value = txtEmail.Text.Trim().ToString();
cmd.Parameters.Add(email);
SqlParameter password = new SqlParameter("@Password", SqlDbType.VarChar, 50);
password.Value = txtPwd.Text.Trim().ToString();
cmd.Parameters.Add(password);
con.Open();
//vali();
clientid = cmd.ExecuteScalar().ToString();
con.Close();
if (clientid != null)
{
//vvv();
Session["Emailid"] = txtEmail.Text.ToString().Trim();
Session["ClientId"] = clientid;
//Session["ClientId"] = ClientId.TypeName.Trim().ToString();
////Session["ClientId"] = strSelect1;
Response.Redirect("WebForm1.aspx");
}
else
lblMsg.Text = "Incorrect EmailId or Password";
}