【发布时间】:2011-04-21 16:01:08
【问题描述】:
idLocals 是数据库中的主键
填充数据表
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 表中多次添加行
【问题讨论】:
标签: c# .net sql ado.net datatable