如何使用XML C#将一个数据集复制到另一个数据集# [英] How to copy one dataset to another dataset using XML C#

查看:128
本文介绍了如何使用XML C#将一个数据集复制到另一个数据集#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个类型化的数据集,即dset1和dset2。



我刚刚将第一个数据集分配给第二个数据集



dset2 = dset1;



当我在第一个数据集dset1发生更改时执行上述操作时,它会反映到dset2。



所以我需要使用ReadXML和WriteXML方法进行复制。



请帮我摆脱这个问题。

解决方案

从.NET FrameWork 1.1开始,System.Data NameSpace提供了一个DataSet.Copy方法,该方法将创建:具有相同结构的新DataSet(表模式,关系和约束)和数据作为这个DataSet。



只需这样做:

 DataSet copyDataSet = OriginalDataSet.Copy(); 


I am having two typed dataset namely dset1 and dset2.

I just assigned first dataset to second dataset by

dset2=dset1;

When I do the above thing whenever a change happens to first dataset dset1 it reflects to dset2.

So I need to copy using ReadXML and WriteXML method.

Please help me to get rid of this problem.

解决方案

Since .NET FrameWork 1.1, the System.Data NameSpace provides a DataSet.Copy method which will create: "A new DataSet with the same structure (table schemas, relations, and constraints) and data as this DataSet."

Just do it:

DataSet copyDataSet = OriginalDataSet.Copy();


这篇关于如何使用XML C#将一个数据集复制到另一个数据集#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆