.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Imran Ghani
Sohaib Khalid

Home >> Code Snippets >> Collections >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

compare two datatables and get the result

Posted By:Venkat       Posted Date: August 04, 2009    Points: 10    Category: Collections    URL: http://www.dotnetspark.com  

compare two datatables in and get the result in another table with the changes rows.

This Method is used to compare 2 dataTable and return the difference in 3rd datatable. In this example we are going to use GetChanges method of dataTable which will give us the difference rows.

Below function takes two parameter of type datatable and return you datatable.

In C#

public static DataTable CompareTwoDataTable(DataTable dt1, DataTable dt2)


DataTable d3 = dt2.GetChanges();




Public Shared Function CompareTwoDataTable(ByVal dt1 As DataTable, ByVal dt2 As DataTable) As DataTable   


Dim d3 As DataTable = dt2.GetChanges()


End Function


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend