如何增加一条数据表到另一个数据表

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

我想增加一条数据表到另一个数据表。我看到了DataTable类有两个方法; 加载(IDataReader的)和合并(数据表)。从文档,既出现合并与现有的数据表输入数据行是否存在的。我会做的合并在一个数据访问层。

I would like to append one DataTable to another DataTable. I see the DataTable class has two methods; "Load(IDataReader)" and "Merge(DataTable)". From the documentation, both appear to 'merge' the incoming data with the existing DataTable if rows exist. I will be doing the merge in a data access layer.

我可以可以美国的IDataReader的,并使用Load方法来合并数据表。或者,我可以加载使用的IDataReader数据集,得到DataSet中的数据表,然后使用合并法合并数据表。

I could could usa an IDataReader and use the Load method to merge the DataTables. Or I could load a DataSet using the IDataReader, get the DataTable from the DataSet, and then use the Merge method to merge the DataTables.

我在想,如果有人能告诉我这是正确的方法来使用?

I was wondering if someone could tell me which is the proper method to use?

另外,让我知道,如果你有不同的建议,就如何完成这个任务。

Alternatively, let me know if you have a different suggestion on how to accomplish this task.

推荐答案

合并需要一个数据表,加载需要一个IDataReader的 - 所以这取决于你的数据层,您可以访问,使用所需的方法。我的理解是,负载将在内部调用合并,但不是100%肯定。

Merge takes a DataTable, Load requires an IDataReader - so depending on what your data layer gives you access to, use the required method. My understanding is that Load will internally call Merge, but not 100% sure about that.

如果你有两个数据表,使用合并。

If you have two DataTables, use Merge.

更多推荐

如何增加一条数据表到另一个数据表

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

发布评论

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

>www.elefans.com

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