aditya immadi

aditya immadi

  • NA
  • 205
  • 71.3k

search againest database

Aug 1 2013 10:08 AM
i'm facing the error while i'm developing search againest database  with the help of autocompletion ,when user enters the  name and clicks the go button i'm trying to pull the data bbut i have this error...none of my google results solve my problem .can any one solve this



Null reference exception was handled by user code
" Object reference not set to an instance of an object."





public partial class search1 : System.Web.UI.Page
    {
        SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlDataAdapter da = new SqlDataAdapter("select * from Candidate1 where name = '"+Session["name"].ToString()+"'", cn);
            DataSet ds = new DataSet();
            da.Fill(ds);
            DataList1.DataSource = ds.Tables[0];
            DataList1.DataBind();
        }
    }


Thanks and Regards

Answers (17)