我有这样的代码:
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()));
}
在最后一行我收到错误消息:
输入数组长于此表中的列数。
为什么?
稍后编辑/添加:
如何解决?