How to merge & sort two datatables

There is two datatables with same column & would like to append one of these datatables on to the end of the other. You may use following code :

Private Function MergeAndSortTables(ByVal Table1 As DataTable, ByVal Table2 As DataTable, ByVal SortBy As String) As DataTable
  Dim View As DataView = Table1.DefaultView
  View.Sort = SortBy

  Return View.ToTable()
End Function

Leave a Reply

Your email address will not be published. Required fields are marked *