Compare 2 Datatables
-
How to compare two dataTables in C#. I have this code but it returns NULL.
DataTable dtReturn = new DataTable();
dtTarget.Merge(dtSource); BindingContext\[dtTarget\].EndCurrentEdit(); dtReturn = new DataTable(); dtReturn = dtTarget.GetChanges(DataRowState.Added);
-
How to compare two dataTables in C#. I have this code but it returns NULL.
DataTable dtReturn = new DataTable();
dtTarget.Merge(dtSource); BindingContext\[dtTarget\].EndCurrentEdit(); dtReturn = new DataTable(); dtReturn = dtTarget.GetChanges(DataRowState.Added);
-
-
I just read this Comparing Datasets using Linq[^] and it states that
To resolve this issue we contacted the Microsoft Support team and after a few days of email exchange, we got the following message: ”I think the root of the issue is that Merge does not change row state. If you create a dataset, then manually change a row value, then row state is tweaked and GetChanges() behaves as expected.”
so it looks like the merge option is not going to work. Perhaps you can use the LINQ option given.
0100000101101110011001000111001011101001