I'm a little confused about DataTable.Merge(). I have two DataTable
objects with the same structure - dtOrig and dtCurrent. The end result
I'm trying to achieve is to get all the rows in dtCurrent that are in
some way different from the corresponding rows in dtOrig so those new/
modified/deleted rows can be processed. My idea was to use
dtOrig.Merge(dtCurrent), and then call dtOrig.GetChanges(). But what I
found is that when the preserveChanges Merge() parameter is
'false' (or not supplied) the values in dtOrig do get updated, but the
RowState stays 'Unchanged'. When preserveChanges is 'true' then the
RowState for all rows becomes 'Modified' but the values in dtOrig are
NOT actually updated! What am I missing here? Is there a better way to
go about this? Thanks.

RE: DataTable.Merge() by pbromberg

pbromberg
Wed May 02 15:09:01 CDT 2007

Depending on "how" you got to your dtOrig and dtCurrent Datatables, the Merge
method may not give you the behavior you are looking for. This page of the
documentation should help clear things up:

http://msdn2.microsoft.com/en-us/library/fk68ew7b.aspx

sorry if dupe, MS' web thang not cooperating today.

Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




"mj2736@yahoo.com" wrote:

> I'm a little confused about DataTable.Merge(). I have two DataTable
> objects with the same structure - dtOrig and dtCurrent. The end result
> I'm trying to achieve is to get all the rows in dtCurrent that are in
> some way different from the corresponding rows in dtOrig so those new/
> modified/deleted rows can be processed. My idea was to use
> dtOrig.Merge(dtCurrent), and then call dtOrig.GetChanges(). But what I
> found is that when the preserveChanges Merge() parameter is
> 'false' (or not supplied) the values in dtOrig do get updated, but the
> RowState stays 'Unchanged'. When preserveChanges is 'true' then the
> RowState for all rows becomes 'Modified' but the values in dtOrig are
> NOT actually updated! What am I missing here? Is there a better way to
> go about this? Thanks.
>
>