I want To Compare Two dataTables And Acheck if The Data of dt1 Column1 Exist In Dt2 Column If true then i have to Check Condition Like Dt1 qty is less than dt2 Qty if this condition is true then i have use dt1 for further process
Dt1
We could try by performing a Join Datatables operation with Join Type as Left Join and DT1 as the First Datatable and DT2 as the Second Datatable. We should be able to get the matching data that is avaiable in DT1 and match it DT2 rows. We could then perform the check with the updated datatable by comparing the Column values of Code if there are no empty values and check Quantities if they are equal or less than Quantity from DT2.
thanks @supermanPunch for reply but my data is going in the false condition again and again here is my sample data
DT1
dT2
I TRIED THIS CONDITION AND APPOSITE OF THIS ALSO
dt_comman.AsEnumerable.All(Function(x)Not String.IsNullOrWhiteSpace(x(“SizeCode”).ToString) AndAlso CDbl(x(“TotalQty”)) <= CDbl(x(“TotalQty_1”)) )
It seems that there are empty row values in your Datatables, Could you check by first performing the update of the Datatable with the below Expression :
(From row1 In dt_re11.AsEnumerable() Join row2 In dt_input.AsEnumerable() On row1(“SizeCode”).ToString Equals row2(“SizeCode”).toString Where Cint(row1(“TotalQty”).ToString) < Cint(row2(“TotalQty”).ToString) Select row1).CopyToDataTable
We need convert the values to double instead of integer if your data contains decimal or floating-point numbers. To do that, you would replace CInt with CDbl in your LINQ expression.
Something like this
(From row1 In dt_re11.AsEnumerable()
Join row2 In dt_input.AsEnumerable() On row1("SizeCode").ToString Equals row2("SizeCode").ToString
Where Double.TryParse(row1("TotalQty").ToString, Nothing) AndAlso Double.TryParse(row2("TotalQty").ToString, Nothing) AndAlso
CDbl(row1("TotalQty")) < CDbl(row2("TotalQty"))
Select row1).CopyToDataTable
Could you show us the Joined Datatable in Debug Mode once again (The One not working), just to get a clear idea on what is happening with the new data ?