its urgent please help me
error msg "object refernce nt set to an instance of object"
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Login1 : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd;
HttpCookie cookie, Counts;
string user, pass, st;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// if (Convert.ToInt32(Request.Cookies["Counters"].Value)<1)
if (Request.Cookies["Counters"] == null)
{
Counts = new HttpCookie("Counters");
Counts.Value = "1";
Counts.Expires = Convert.ToDateTime("05/06/2010");
//Response.Write(Counts.Value.ToString());
Response.Cookies.Add(Counts);
}
}
}
protected void btnLogin_Click1(object sender, EventArgs e)
{
try
{
con = new SqlConnection("Data Source=HOME-E83A512B4A;Initial Catalog=Banking;Integrated Security=SSPI");
con.Open();
Response.Write(con.State.ToString());
cmd = new SqlCommand("Select CustomerID,AccountNo,LPin from tblCustomers where AccountNo='" + txtUser.Text + "' and LPin='" + txtPass.Text + "'", con);
SqlDataReader dr;
dr = cmd.ExecuteReader();
if (dr.Read())
{
Session.Add("Customerid", dr.GetValue(0).ToString());
Session.Add("AccountNo", dr.GetValue(1).ToString());
user = dr.GetValue(1).ToString();
pass = dr.GetValue(2).ToString();
// Response.Redirect("UserHome.aspx");
dr.Close();
}
if (txtUser.Text == user && txtPass.Text == pass)
{
cookie = new HttpCookie("UN", txtUser.Text);
cookie.Expires = Convert.ToDateTime("05/06/2010");
Response.Cookies.Add(cookie);
//Response.Write("Login Succeeded");
// lblmsg.Text = "Login Succeded";
}
else
{
int Cnt = 0;
Counts = new HttpCookie("Counters");
Counts.Value = Convert.ToInt32(Request.Cookies["Counters"].Value + 1).ToString();
Counts.Expires = Convert.ToDateTime("05/06/2010");
// Counts.Value = Convert.ToInt32(Request.Cookies["Counters"].Value + 1).ToString();
Response.Cookies.Add(Counts);
//Request.Cookies["Counters"].Value = (Convert.ToInt32(Request.Cookies["Counters"].Value ) + 1).ToString();
Response.Write(Request.Cookies["Counters"].Value);
Cnt = Convert.ToInt32(Request.Cookies["Counters"].Value);
if (Cnt >= 3)
{
Response.Write("Your Account has been blocked");
// lblmsg.Text = "Your Account is Blocked";
}
// Response.Write();
}
}
catch (Exception ex)
{
Response.Write("<script> alert('" + ex.Message.ToString() + "') </script>");
}
}
}