0
該數組通過數據表上的linq查詢獲得。當我嘗試將其添加到另一個數據表時,它會提供該行屬於另一個表的異常。將數據行數組中的數據行添加到數據表頂部
需要將行添加到表的頂部不在底部
DataRow[] recovery_rows = Sub_DataTable.Select("ProductId = " + last_product_id.ToString() + ""); //Sub_DataTable is a datatable
for (int rev_row = 0; rev_row < recovery_rows.Count(); rev_row++)
{
DataRow r_new = recovery_rows[rev_row];
// r_new = recovery_rows[rev_row];
dt_sub.Rows.InsertAt(recovery_rows[rev_row], 0);
}
什麼是確切的異常和引發它的行? – dotctor
當然你可以谷歌這一個......這裏也許? http://stackoverflow.com/questions/722052/this-row-already-belongs-to-another-table-error-when-trying-to-add-rows –
不能使用@邁克爾B因爲需要添加行總是在頂部 –