Two DataTable Query Issue

Hi,

I have an issue to delete data in datatable D1 which is match data from datatabe from D2.
I try run below query but I did not get the result which is supposed delete the data that match from D2.

I really need help to fix below Query.

Data Table as

D1
image

D2
image

Expected Result
image

I did try use this query

D1.AsEnumerable().Where(Function(row) Not D2.AsEnumerable().Select(Function(r) r(3).ToString).Any(Function(x) x = row(3).ToString)).CopyToDataTable

Expected Result

image

But I got this result
image

Thank you
Regards
Jamuri

check the result while debugging and let it write to a new Worksheet. Let us know the result

Yes I did try write to the new worksheet. and still got the same result.
My query should be correct right?
My Source don’t have a headers.

give a try on

(From d in D1.AsEnumerable()
Where not D2.AsEnumerable().Select(Function(r) r(2).ToString.Trim).Any(Function(x) x = d(2).ToString.Trim)
Select res = d).CopyToDataTable

DT1.xlsx (11.1 KB)
DT2.xlsx (10.0 KB)

Attached, sample files

please try modified statement. Kindly note column index is 0 based. so accessing the third col will use 2 as index

result still the same.

can you share your xaml with us for further review?

MainissuQxaml.xaml (14.6 KB)

My xaml as per attached

got it run with your excels by using following statement

(From d In D1.AsEnumerable()
Where Not D2.AsEnumerable().Select(Function(r) r(1).ToString.Trim).Any(Function(x) x.Equals(d(2).ToString.Trim))
Select res = d).CopyToDataTable

untick add headers for dt2

1 Like

Hi Peter,

manage to get the output…
Thank you very much.

Regards
Jamuri

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