HOW to compare two datatable columns?

I have two excel files i.e. two data tables

  • One data table contains "Employee " Column & Second data table also contains "Employee " Column

Now the scenario is i have to check the first data table column
(employee name) is present or not in second data table?

Thanks in advance

preactice_1.zip (25.9 KB)

Hi try this example , from other thread

Before comparing ensure the following,

  1. No. of Rows in dt1 and dt2 should be equal.
  2. Column names should be in sync. If not, please update the column names accordingly.

Use this linq to compare,

unmatchedDt = If((From table2 In dt2.AsEnumerable() Where Not dt1.AsEnumerable().Any(Function(f) f.Field(Of String)(“Column1”) = table2.Field(Of String)(“Column1”) AndAlso f.Field(Of String)(“Column2”) = table2.Field(Of String)(“Column2”)) Select table2).Count=0, New datatable, (From table2 In dt2.AsEnumerable() Where Not dt1.AsEnumerable().Any(Function(f) f.Field(Of String)(“Column1”) = table2.Field(Of String)(“Column1”) AndAlso f.Field(Of String)(“Column2”) = table2.Field(Of String)(“Column2”)) Select table2).CopyToDataTable)

If (unmatchedDt.Rows.Count=0), Then {Match} Else {Unmatch}

Please refer this xaml for more details.

datatable compare.xaml (12.2 KB)

Regards
Ahmad