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.
image

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,
Yash

Hi @yash.choursia ,

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

Regards,

hi @vishal.kp, Please Help.
image
This is my uploading_dt.

image
This is my RTGS_master.

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

Hi,

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

Regards,

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

HI,

All right. How about the following?

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

Then

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

Sample20230414-7L.zip (9.0 KB)

Regards,

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