2014年1月11日 星期六

[ASP.NET][C#] [EN] This Row already belongs to another table [CHT] 這個資料列已經屬於其他資料表。

紀錄一下今天碰到的問題

[EN] This Row already belongs to another table  [CHT] 這個資料列已經屬於其他資料表。

今天利用一個 Function 回傳 DataRow,想要加入至另外一個DataTble,
但是發現無法使用Data_Table.Rows.Add(Data_Row); 

系統提示[EN] This Row already belongs to another table  [CHT] 這個資料列已經屬於其他資料表。

Google一下,有一位網友也碰到此問題,

發現是需要使用另外一個方法Data_Table.ImportRow(Data_Row);

使用上述方法即可。