Compare datasets with 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!



From http://www.developmentnow.com/g/7_0_0_0_0_0/dotnet-framework-adonet.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
.



Relevant Pages

  • Compare datasets with hash values or possibly another way?
    ... hash values of the datasets and compare those. ... ' Create a new instance of memory stream ... Dim formatter As New BinaryFormatter ...
    (microsoft.public.vstudio.general)
  • sha1 problem
    ... I'm I'm trying to compare 2 hash values using sha1 one written in vb.net ... The value I get in my vb.net code does not match the python code, ... Dim SHAhash As New SHA1Managed ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • RE: Hi All, need urgent help please.
    ... Are you comparing all the books against a 'master' copy or each book against ... Is there a set range of cells in each book that you want to check or is it ... The code below will compare specific sheets and list the results. ... Dim wksSheet1 As Worksheet ...
    (microsoft.public.excel.programming)
  • Re: Hash a range, output a Long Integer?
    ... Re the GetMD5Hash function in the root message. ... The problem with GetMD5Hash is I get the same hash if the cell value is ... I get a hash that that changes on the content of the cells. ... Dim hHash As Long ...
    (microsoft.public.excel.programming)
  • Re: checkboxes not updating and how do I move to next record?
    ... What I'm trying to do is compare the name fields of two tables. ... check off both boxes. ... I need the onEPLSDb checkbox checked off and the ... Dim RecordScrubbed As Boolean ...
    (microsoft.public.access.formscoding)

Loading