Compare datasets using hash values or possibly another method?
I have two datasets with the same exact structure that I would like to compare. I would like to know if there is any difference in the data between them. I don't need to know what the differences are, only that there is a difference.
From what I have read about hash values, I thought that I could obtain the hash values of the datasets and compare those. If the hash values were different, I would know that there is a difference in the data in the datasets. I tried this approach, but I found that even when I changed a string in one of the fields in one dataset, the hash values calculated were the same. I am not sure if I am missing something here?
This is the code I performed on both datasets to get the hash values...
' Create a new instance of memory stream
Dim ms1 As New MemoryStream
Dim formatter As New BinaryFormatter
'Serialize dataset to memory stream
formatter.Serialize(ms1, dsCurrent)
'Compute hash value for stream
Dim hashvalue1 As Byte() = CType(CryptoConfig.CreateFromName("MD5"), HashAlgorithm).ComputeHash(ms1)
Then I changed the hash byte array to a hex string...
Dim i As Integer
Dim sOutput1 As New StringBuilder(hashvalue1.Length)
For i = 0 To hashvalue1.Length - 1
sOutput1.Append(hashvalue1(i).ToString("X2"))
Next
Dim strHashValue1 As String = sOutput1.ToString
I then compared the hex strings.
Is there another way other than hash values that I could use to compare the data in the datasets? I tried dataset.merge and found that when merging the second dataset into the first, the rowstate of the rows that were different between the two datasets did not change to 'modified', but remained at 'unchanged'.
Any help would be greatly appreciated!!
Thanks!

