Datatable reconciliation

@shreyaank ,

Maybe you could try with the below steps :

  1. Assuming you have read the data from the two sheets and have got the datatables, let’s say DT1 and DT2.

  2. Now, We will fetch the ID and year values from DT1 and concatenate it and get all the concatenated values as a list/array.

IdYearArray = DT1.AsEnumerable.Select(Function(x)x("ID").ToString.Trim+x("Year").ToString.Trim).Distinct.ToArray

Here, IdYearArray is of the type Array of String.

  1. Next, we filter the DT2 datatable with the fetched IdYear values from DT1 like below :
DT3 = DT2.AsEnumerable.Where(Function(x)IdYearArray.Contains(x("ID").ToString.Trim+x("Year").ToString.Trim)).CopyToDatatable

Here, DT3 is the resultant datatable (needs to be created).

Also, Check the below on handling Exceptions on direct CopyToDatatable.

Let us know if you are able to follow the approach mentioned.