I'm using the following subroutine. The two different XML files are
identical with the exception of three additional records in the second
one. One has 450 records, and the other has 453. After merging, I get
903 records. I guess what I expected was 3 records; just the
differences in the two.
The two tables have the exact same structure, etc....
So am I misinterpreting how to do this? It seems to me that the merge
should produce only three new records!
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnStart.Click
Dim dsOld As DataSet = New DataSet
Dim dsCurr As DataSet = New DataSet
Dim dsTemp As DataSet = New DataSet
Dim dsChanges As DataSet = New DataSet
dsTemp.DataSetName = "SERVERINFO"
dsChanges.DataSetName = "SERVERINFO"
dsOld.ReadXml("c:\dsOld.xml", XmlReadMode.ReadSchema)
dsCurr.ReadXml("c:\dsCurr.xml", XmlReadMode.ReadSchema)
dsTemp.Merge(dsOld)
dsTemp.AcceptChanges()
dsTemp.Merge(dsCurr)
dsTemp.WriteXml("c:\dsTemp.xml", XmlWriteMode.DiffGram)
dsChanges = dsTemp.GetChanges()
dsChanges.WriteXml("c:\dsChanges.xml", XmlWriteMode.DiffGram)
Debugger.Break()
End Sub
Latish Sehgal - 29 Mar 2007 18:37 GMT
The merge function is used to merge in new changes.
Check out http://msdn2.microsoft.com/en-us/library/06t089d7.aspx
Maybe you can try changing the DataRowState of the 2nd dataset before
merging.
Hope this helps.