none
DataTable.Merge but preserve changed rows RRS feed

  • Question

  • I have a pretty simple question here.

    I have two data tables that I am attempting to merge.  The merge is happening beautifully.  However, I need to know what values have changed.  It is my understanding that if I were to call .GetChanges() after a merge, I would get nothing, as if .AcceptChanges() had already been called.  Basically, I need the exact funtionality of a .Merge() without the changes being accepted.  Is there some way to do this, or will I need to go through the columns of each table and compare them manually?

    I already have some functionality in my code to compare the columns of my datatable to see what has changed, however it only does this if there are changes made to a row.  My merge is keeping these changed rows from showing, so my columns are not comparing.

    Thanks,

    Joe Sullivan
    Data Systems Administrator
    Great Commission Ministries

    Friday, May 26, 2006 11:16 AM

Answers

  • A quick update on this for anyone else that has had the same problem:

     

    Unfortunately, I discovered that there is no way to keep a merged dataset from going to the modified state. I ended up creating my own merge function that cycled through the rows and compared the value in each column, updating the value if it was different. Why Microsoft's merge does not do it this way I have no idea. The parsing through the rows is not that costly and I imagine that's what their merge does anyways.

     

    Joe Sullivan

    Monday, August 4, 2008 8:07 PM