Fix code

I am using the following code to find whether data in two data tables dt1, dt2 is different, output goes to dtResult. This is throwing an error “System.ArgumentNullException” Can you please help to fix? Thanks a lot,



Hi @A_Learner ,

Is the Schema of the Datatable the same ? Meaning it has the same columns ?

Also, for the Data supplied, do we get mismatch results or there are no mismatches ?

Check also both the Datatable values by performing a Debug.

1 Like

Thank you,
The code is supposed to detect mismatch.
I verified column names in dt1, dt2 and dtResult to be the same.

@A_Learner ,

We do know the code performs the mismatch, but does the data correspond to it and provide us with the mismatch or are there no mismatches for the data ?

Also, try to avoid direct CopyToDatatable() after Filtration as mentioned below :


As per error looks like all are matching your except is not returning any data

Before doing copydatatable use .Count>0 in if condition and on then side use copytodatatable and on else side it means there is not even one row


Thank you, @supermanPunch for the pointer.

Changed the code slightly. Still getting error “Value cannot be null” at the assignment activity.

dataRow = dt1.AsEnumerable().Intersect(dt2.AsEnumerable(),System.Data.DataRowComparer.Default)

if (dataRow.ToList.Count > 0) then copy to result datatable


Is the dt1 and dt2 having data?


Yes, thank you. I am reading from Excel files. Both data tables have data.


Can you please check if there is a duplicate datatable with same name and different scope


Yes, this is the reason. Thanks @Anil_G
Thank you, @supermanPunch

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.