Hi Team I have a data table called DT1 and DT2
In DT1 it is stable.
In DT2 data will change every time.
With Example I explain below.
DT1:
Slno
PrimaryName
DivisonNo
1
ABC
1234
2
Exce
5432
3
CHET
2345
DT2:
Slno
PrimaryName
DivisonNo
1
MSLA
234
2
CHET
2345
3
Exce
5432
Expected OP:
1
ABC
1234
2
Exce
5432
3
CHET
2345
1
MSLA
234
Note: Every Time we are add all new Data from DT2 to DT1, These are all in the loop mode. New data were add to the DT2 so we are check all new data Dt2 with old Dt1.
If we find all three data rows are same then we need to throw exception.
Example: If the data of Dt2 all values are match with DT1 then we need to throw exception
Read both DataTables and assign into variables DT1 and DT2
It Check if all rows in DT2 match with DT1. IF Match Throw Eception Else Add Row to DT1.
If (Not DT2.AsEnumerable().Any(Function(row) Not DT1.AsEnumerable().Any(Function(r) r("PrimaryName").ToString().Equals(row("PrimaryName").ToString()) AndAlso r("DivisonNo").ToString().Equals(row("DivisonNo").ToString())))) Then
Throw New Exception("Exception: All rows in DT2 match with DT1")
End If
For Each row In DT2.AsEnumerable()
DT1.Rows.Add(row.ItemArray)
Next
No, it will not throw an error in that case. It will only throw an error if all rows in DT2 match with DT1.
If three out of four rows in DT2 match with DT1 and one row is unique, it will add that row to DT1
I have a doubt if dt2 values are changed when it is in loop?
because every loop dt2 add with new data on that time agin we need to compare with dt1 data table and if it match throw exception if not we need to add the data row to dt1 from dt2.
It was throwing error due to Studio and package difference I guess.
I have downgraded the packages to lowest version available in Studio 2023.10.3
If still the whole solution don’t works, copy only the CheckDuplicate.xaml to your project and this should work as there is no dependency on other things.