DataTable dt = new DataTable();
DataRow[] dr = (DataTable)dsData.Tables[0].Select("Some Criteria");
dt = (DataTable)dsData.Tables[0].clone();
dt.Rows.Add(dr); //line causing the error
以上代码在粗体行中抛出错误如下
"Unable to cast object of type 'System.Data.DataRow' to type
'System.IConvertible'.Couldn't store in pipelinesubstatusid Column.
Expected type is Decimal."
你可以帮助我克服这个问题
答案 0 :(得分:0)
试试这个:
foreach(var row in dr)
{
var r=dt.NewRow();
r.ItemArray = row.ItemArray;
dt.Rows.Add(r);
}
或
foreach(var row in dr)
{
dt.Rows.Add(row);
}