I have code like this:
DataTable dtLevel1 = dtCategories.Clone();
DataTable dtLevel2 = dtCategories.Clone();
// i can workaround this with CopyToDataTable()
dtLevel1.Rows.Add(dtCategories.Select("id = 123")); // error
// but here similar situation, I cant use CopyToDataTable() method here
// because it will overwrite whole table in next loop run
foreach (DataRow dr in dtLevel1.Rows)
{
dtLevel2.Rows.Add(dtCategories.Select("[pid] = " + dr["id"].ToString()));
}
On last line I'm getting error that says:
Input array is longer than the number of columns in this table.
Why?
Edit/added later:
How to fix it?