Error
-
Error :Object reference not set to an instance of an object. Here is my code. SqlConnection conn = new SqlConnection("Data Source=servername;Database=dbCustom;Integrated Security=SSPI"); SqlCommand comm = new SqlCommand("GetProjects", conn); SqlDataAdapter adapter = new SqlDataAdapter(comm); DataSet ds = new DataSet(); adapter.Fill(ds, "Project_ID"); ProjectidList.DataSource = ds; * it says error is on this line ProjectidList.DataMember = ds.ToString();
-
Error :Object reference not set to an instance of an object. Here is my code. SqlConnection conn = new SqlConnection("Data Source=servername;Database=dbCustom;Integrated Security=SSPI"); SqlCommand comm = new SqlCommand("GetProjects", conn); SqlDataAdapter adapter = new SqlDataAdapter(comm); DataSet ds = new DataSet(); adapter.Fill(ds, "Project_ID"); ProjectidList.DataSource = ds; * it says error is on this line ProjectidList.DataMember = ds.ToString();
Are there any values in the dataset. Your query might fail and in the dataset there are no tables...thus generating an error.
I will use Google before asking dumb questions
-
Error :Object reference not set to an instance of an object. Here is my code. SqlConnection conn = new SqlConnection("Data Source=servername;Database=dbCustom;Integrated Security=SSPI"); SqlCommand comm = new SqlCommand("GetProjects", conn); SqlDataAdapter adapter = new SqlDataAdapter(comm); DataSet ds = new DataSet(); adapter.Fill(ds, "Project_ID"); ProjectidList.DataSource = ds; * it says error is on this line ProjectidList.DataMember = ds.ToString();
Im gonna guess that something went wrong when you tried to fill your dataset, or ProjectidList was not initialised properly. Add an if statement to see if either of them are null or something.
My current favourite word is: PIE! Good ol' pie, it's been a while.
-
Error :Object reference not set to an instance of an object. Here is my code. SqlConnection conn = new SqlConnection("Data Source=servername;Database=dbCustom;Integrated Security=SSPI"); SqlCommand comm = new SqlCommand("GetProjects", conn); SqlDataAdapter adapter = new SqlDataAdapter(comm); DataSet ds = new DataSet(); adapter.Fill(ds, "Project_ID"); ProjectidList.DataSource = ds; * it says error is on this line ProjectidList.DataMember = ds.ToString();
Two reasons: 1) Are you missing a runat="server" for ProjectidList in the ASPX page? 2) Is ds null?
Vasudevan Deepak Kumar Personal Homepage
Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson -
Error :Object reference not set to an instance of an object. Here is my code. SqlConnection conn = new SqlConnection("Data Source=servername;Database=dbCustom;Integrated Security=SSPI"); SqlCommand comm = new SqlCommand("GetProjects", conn); SqlDataAdapter adapter = new SqlDataAdapter(comm); DataSet ds = new DataSet(); adapter.Fill(ds, "Project_ID"); ProjectidList.DataSource = ds; * it says error is on this line ProjectidList.DataMember = ds.ToString();