Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to compare datatables ?

Status
Not open for further replies.

djwaxi

Programmer
Jul 26, 2005
1
NL
Hello,

I've got 2 DataTables with the same data.
If one DataTable is changed an action will be taken.
How do i compare the contents of 2 datatables ?

Already thnx.
greetz dj
 
hey,

You could write your own compare function. I wrote one that I cannot seem to find the source code for now, but it was basically just a series of checks...using a foreach datarow and foreach datacolumn to compare the data types. Also, just for a cursory quick check, you can check the row and column counts. If they are different then something has been added or deleted to one of the tables (of course, assuming that they were exactly the same at one point. As far as C# having a way to do this for you, I'm not sure how, but I'm sure there is something already created to do this...maybe a .equals() method.

Hope this gives a starting point.

Good luck
-Kevin

- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts.
 
The Equals method on the datatable should work for you.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top