Blog‎ > ‎

Compare Two DataTables in .Net

posted May 1, 2011, 9:12 PM by Jeremy Walker   [ updated May 2, 2011, 10:36 AM ]
According to the Remarks section of this article on MSDN, the methods DataTable.Merge() and DataTable.GetChanges() could be used together to obtain another DataTable which contains the rows that make the difference between the two. Additionally, if the returned DataTable contains any rows then obviously the two DataTables don't match.

This is how I've used it:

DataTable diffTable = table1.GetChanges();