17
Answers

search againest database

aditya immadi

aditya immadi

11y
1.1k
1
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)