因此,我一直难以让dataset.Merge正常工作,它似乎不想从同名和模式的数据表中追加记录。有关该问题,请参阅https://stackoverflow.com/questions/15124504/cannot-get-dataset-merge-to-work。
我找到了一个使用GetXML的变通方法,现在我将回答这个问题。
发布于 2013-02-28 08:25:11
' 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)新的MergedDS将包含您的所有表,并且相同名称的表将合并它们的记录。我只在我相当复杂的数据集(分别为4个和15个具有关系和其他约束的表)上进行了测试。
https://stackoverflow.com/questions/15125251
复制相似问题