此错误,同时添加一个数据表,从一个数据集到另一个存在的 数据表已属于另一个数据集。
dsformulaValues.Tables.Add(m_DataAccess.GetFormulaValues (dv.ToTable.DefaultView.ToTable(假,strSelectedCols))。表(0))解决方案
像其他答复指出,你所看到的错误是因为你正在试图添加到DataSet中的数据表已经是一个不同的一部分数据集。
一种解决方案是Copy数据表和分配复制到其他数据集。
dtCopy = dataTable.Copy() ds.Tables.Add(dtCopy)
复制的数据表将具有以下结构和所复制的数据表的数据
如果您只想DataTable的结构,叫Clone代替。
dtCopy = dataTable.Clone()This error is occuring while adding one datatable from a dataset to another ."DataTable already belongs to another DataSet."
dsformulaValues.Tables.Add(m_DataAccess.GetFormulaValues (dv.ToTable.DefaultView.ToTable(False, strSelectedCols)).Tables(0))解决方案
Like the other responses point out, the error you're seeing is because the DataTable you're attempting to add to a DataSet is already a part of a different DataSet.
One solution is to Copy the DataTable and assign the copy to the other DataSet.
dtCopy = dataTable.Copy() ds.Tables.Add(dtCopy)The copied DataTable will have the structure and data of the copied DataTable.
If you only want the structure of the DataTable, call Clone instead.
dtCopy = dataTable.Clone()
更多推荐
数据表已属于另一个数据集
发布评论