idLocals
是數據庫主鍵異常,同時將多行添加到數據表。無法保存<System.Data.DataRowCollection>
填充DataTable中
oDtLocalCharge = bll.GetData();
我正在複製的數據表中的另一個功能
dtLocalCharges = oDtLocalCharge.Copy();
並嘗試使用以下代碼添加行
DataRowCollection drr = oDtLocalCharge.Rows;
dtLocalCharges.Rows.Add(drr);
當我嘗試將行添加到數據表中,我得到如下錯誤
Error:
{System.ArgumentException: Unable to cast object of type 'System.Data.DataRowCollection' to type 'System.IConvertible'.Couldn't store <System.Data.DataRowCollection> in idLocals Column. Expected type is Int32. ---> System.InvalidCastException: Unable to cast object of type 'System.Data.DataRowCollection' to type 'System.IConvertible'.
可能是主鍵idLocals
導致問題 是什麼問題?
我該如何解決這個問題?我想在dtLocalCharges
表中添加多個行
datatable.ImportRow(OtherDataTable)! – Thakur 2010-10-07 06:35:27
好的!我沒有看整個DataTable API。 – 2010-10-07 11:49:00