Compare 2 datatables with the help of linq and update one datatable with rest to other table

Hi Team,
I have 2 datatables and want to match rows of a particular column of one datatable to another datatable and depending on that result, I want to update one datatable using values from another datatble. I have done this using 2 for each loop and an if statement. I am attaching a screenshot of the same. Please help mw with this linq because using for each is taking much time because my dataset is huge.

Here i want to check column “CONCAT1” of DT_Uploading and “CONCAT” of RTGS_Master_Sheet and depending of the search, i want to update values in DT_Uploading with respect to RTGS_Master_Sheet.
Thanks Team,

Hi @yash.choursia ,

It would be helpful if you can share a screenshot/file of your input and expected output.


hi, Please Help.
This is my uploading_dt.

This is my RTGS_master.

This is my output table, which is basically an updated version of uploading_dt.


I suppose the final row of table3 should has not A3734 but A1234. Is this correct?


Yes, @Yoichi . Sorry for the mistake. Please help.


All right. How about the following?

dictMaster = dt2.AsEnumerable.ToDictionary(Function(r) r(1).ToString,Function(r) r(0).ToString)


dt3 = dt1.AsEnumerable.Select(Function(r) dt1.Clone.LoadDataRow({if(dictMaster.ContainsKey(r(1).ToString),dictMaster(r(1).ToString),r(0)),r(1)},False)).CopyToDataTable (9.0 KB)


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.