I have a scenario where i have two data table dt1 and dt2. In dt1 there are two columns A and B and in dt2 there is a column c. So i want to match the column C value of dt2 in the column A of dt1. And which values are match from C to A then in dt1 there should be “Yes” in B column of dt1. And which value’s are not matched there should be “No” in Colum B.
(From d In dt1.AsEnumerable
Let a = If(dt2.AsEnumerable().Select(Function(r) r("C").ToString).Any(Function(x) x = d("A").ToString), "Yes", "No")
Let ra = d.ItemArray.Take(d.ItemArray.Length-1).Append(a).toArray
Select dt_result.Rows.Add(ra)).CopyToDataTable
It should work although I am sure there are faster solutions.
This checks string values, please edit if you need a different data type.
But what is dt_result data table. I have Created a data table variable named as dt_result and assign whole query result into it, but it’s showing an error like, Assign: Object reference not set to an instance of an object.