数据表已属于另一个数据集

编程入门 行业动态 更新时间:2024-10-28 14:30:52
本文介绍了数据表已属于另一个数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

此错误,同时添加一个数据表,从一个数据集到另一个存在的 数据表已属于另一个数据集。

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()

更多推荐

数据表已属于另一个数据集

本文发布于:2023-11-12 00:00:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579913.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据表   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!