I have two DataTables, DT1 and DT2(Column1, Column2, Column3, Column4, Column5) . I want to find the match and unmatch column values and put in different sheet . How can I achieve this using LINQ. As there are lot of data forloop takes lot of time to process. I want to achieve this using LINQ
For example ,if Column1 and Column3 is match it show give the column name and its values. If Column 4 and Column 5 unmatch it should give column name and column values.
I have two excels DT1 and DT2 . I need to compare two excel column values and if the values dont match need to populate in another excel sheet the unmatch column values
Helli @marina.dutta ,
Correct me if I m worng, so you are comparing two datatable , based a certain column value, and if a particular row matched put that into lets say Sheet1 and if the do not match put that row into another sheet lets say Sheet2
Regards
I got the two rows that are unmatched using query dt_pdfout.AsEnumerable().Except(dt_out_sales.AsEnumerable(),System.Data.DataRowComparer.Default).CopyToDataTable however My unmatched columns are Total Contract Value and Scheduling&Delivery . I am getting entire rows . Is it possible to get the only column values that are unmatched .
For example here in this case Total Contract Value and Scheduling&delivery is unmatched . I just want these two values
For each row of dt1 select and load the data into dt3…
dt1.AsEnumerable.Select(function(x) dt3.Clone.LoadDataRow
First column to be quote number
({x(“Quote Number”).ToString,
From the matching row in dt2 with quote number in dt1…get the row as itemarray
String.Join(“,”,dt2.AsEnumerable.First(function(y) y(“Quote Number”).ToString.Equals(x(“Quote Number”).ToString)).ItemArray.
For each item in the array check if the value in dt2 and dt1 are matching then dont get column name else get the corresponding columnname and add it as second item or second column to dt3
Select(function(y,i) If(Not y.ToString.Equals(x(i).ToString),dt1.Columns(i).ColumnName,“”)).Cast(Of String).Where(function(z) Not STring.IsNullOrEmpty(z)))},False)).CopyToDataTable