I have two tables and I need to compare them. I need to build a third table that contains the data in table1 that was not found in table 2. I was able to figure out how to find the ones that match but I can’t figure out how to find the ones that don’t match:
(From da In dtfull.AsEnumerable
Join db In dtpart.AsEnumerable
On da(0).ToString.Trim Equals db(0).ToString.Trim
Select da).CopyToDataTable
Do I have to somehow change the equals to not equals?
Note: both tables only have one column each with no name.
yah instead of In_DataTable1 mention as DTFull
and In_DataTable2 mention as DTPart
where for column name
instead of In_DT2_ColName_To_Match mention the column name from DTPart which you want to compare with DTFull.
and instead of In_DT1_ColName_To_Match mention the columnname from DTFull
we can mention the column index that usually starts from 0 for the first column
based on which we can just mention the column index without double quotes like this
Datatable Out_NonMatched_Data = DTPart.AsEnumerable().Where(function(row) Not DTFull.AsEnumerable().Select(function(r) r.Field(Of String)(columnindex)).Any(function(x) x = row.Field(Of String)(columnindex))).CopyToDataTable()
Code is:
DTPart.AsEnumerable().Where(function(row) Not DTFull.AsEnumerable().Select(function(r) r.Field(Of String)(0)).Any(function(x) x = row.Field(Of String)(0))).CopyToDataTable()
As you mentioned finding the Common rows we’re Not the Problem at your so end. So in the xamls you will find on how to use the commmons rows to identify the unmatching rows