如何使用.getXML代替.Merge做dataset.Merge [英] How to do a dataset.Merge using .getXML instead of .Merge

查看:101
本文介绍了如何使用.getXML代替.Merge做dataset.Merge的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我一直有麻烦dataset.Merge工作的权利,这似乎并没有要追加的同名和schema'd数据表的记录。请参见无法获取dataset.merge工作该问题。

我发现使用的getXML我现在回答一个解决办法。

解决方案

 从你的数据集合并XML:
tempXML和放大器; = Dataset1.GetXML()
tempXML和放大器; = Dataset2.GetXML()
从我使用的XML&LT'删除根标签; FullRecord>矿
tempXML = tempXML.Replace(&其中; FullRecord>中,).Replace(&所述; / FullRecord>中,)
创建一个新的数据集与修改后的XML。一定要把根标签回第一
MergedDS =新的数据集
RDR =新StringReader(&​​LT; FullRecord>中和放大器; tempXML&安培;< / FullRecord>中)
MergedDS.ReadXml(RDR)
 

MergedDS 将所有的表和相同的命名表中都会有他们的记录相结合。我只对我相当复杂的数据集(4和15个表分别与关系等方面的限制。)进行了测试。

So I have been having trouble getting dataset.Merge to work right, it does not seem to want to append records from identically named and schema'd datatables. See Cannot get dataset.merge to work for that issue.

I found a workaround using GetXML which I will now answer.

解决方案

' Merge the XML from your datasets:
tempXML &= Dataset1.GetXML()
tempXML &= Dataset2.GetXML()
' Remove the root tags from the XML I used <FullRecord> for mine
tempXML = tempXML.Replace("<FullRecord>", "").Replace("</FullRecord>", "")
' Make a new dataset with the modified XML. Be sure to put root tag back first
MergedDS = New DataSet
rdr = New StringReader("<FullRecord>" & tempXML & "</FullRecord>")
MergedDS.ReadXml(rdr)

The new MergedDS will have all of your tables and the same named tables will have their records combined. I have only tested it on my rather complex datasets (4 and 15 tables respectively with relationships and other constraints.)

这篇关于如何使用.getXML代替.Merge做dataset.Merge的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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