DataTable problem, help help

  • Thread starter Thread starter pei_world
  • Start date Start date
P

pei_world

I have two database tables, "nodes" and "relation".
nodes - nodeid, name..
relation - parentid, childid
when I use the following codes, it give me error.

//======================================
DataTable test = rootDS.Tables["relation"];
MessageBox.Show(test.Rows[0]["parentid"].ToString());

program return said can find column "parentid",???
why is that?
 
Try if this works:
DataTable test = rootDS.Tables["relation"];
MessageBox.Show(test.Rows[0][0].ToString());

If so, you can find the name of the column by using the Name property like
this:
test.Tables[0].Columns[0].ColumnName;
 
Debugging step #1:
loop through the test.Rows[0].columns and check all the column names to see
what's in there.

-Rob Teixeira [MVP]
 
Back
Top