Check that you have the correct names for the tables and columns. You are referencing them by name and geting a null back it looks like for the table so that when you go to check for the column in that table it blows up because the table return null.
string strSQL = string.Empty;
string customerIds = "1,2";
strSQL = "SELECT FirstName ,LastName, CustomerId FROM Disp_Customers WHERE CustomerID IN (" + customerIds + ")" +
"SELECT DisputeID, CustomerID FROM Disp_Disputes WHERE CustomerID IN (" + customerIds + ")";SqlConnection cn = new SqlConnection();
cn.ConnectionString = ConfigurationSettings.AppSettings["connectionString"];
SqlDataAdapter cm = new SqlDataAdapter(strSQL, cn);
cm.TableMappings.Add("Disputes", "Disp_Disputes");DataSet ds = new DataSet();
cm.Fill(ds, "Disp_Customers");ds.Relations.Add("CustomerDisputes", ds.Tables["Disp_Customers"].Columns["CustomerId"], ds.Tables["Disp_Disputes"].Columns["CustomerId"]);
ds.Relations[0].Nested = true;PrintRepeater.DataSource = ds.Tables["Disp_Customers"];
PrintRepeater.DataBind();
Saturday, March 24, 2012
object reference not set to an instance of an object
I am trying to populate data in a repeater control but am getting a "object reference not set to an instance of an object" error. The line it points to is in red below. Any ideas on what i'm doing wrong?
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment