Comparing two datatables

I have 2 datatables. SVTaskDataDT and VCFiltered DT.
SVTaskDataDT has the following data:
PunchCodeSV VendorTotalSV
2510 100
3000 0

VCFilteredDT has the following data:
DNBGR2 2510 100
DNBGR2 2501 100
DNBGR2 9901 18.75

I am trying to compare these two datatables in the following manner. But I am not getting any common rows which I should be. Could anyone provide insight as to what I may be missing here.


1 Like

Hi @parimala.prata,
Check this below link:


Use this query it will return dataTable. You can use datatable.Rows.Count to check the records in the new datatable that query will return.

MatchedDT (DataTable) = Dt1.AsEnumerable().Where(Function(row) Dt2.AsEnumerable().
Select(Function(r) (r.Field(Of String)(0)).Trim).Any(Function(x) x = (row.Field(Of String)(0)).Trim)).

Hope it will work

Hi Ghazanfar,

how do I output the MatchedDT. I am trying to write range and it doesnt seem to like it. am i missing something


thank you,

1 Like

first check the rows in the MatchedDT by MatchedDT .Rows.Count.

If count >0 then use write range activity and give MatchedDT as datatable.

Hey @parimala.prata,

Can you check ColumnType of PunchCodeSV and TASK_CODE_FK?

I think one of them is Int and the other one is String. Then, when try to join they are considered different values (for example, 2510 is not equal to “2510”) and you don’t get any common row.

You can use this to change column type:

I cannot tell you how appreciative I am. This worked and i am able to find the common rows. you are right. the data was not matching due to different datatypes of the columns. I didnt have to use the query anymore. Just the inner join worked.


thank you,

1 Like


Glad to help you, my friend :slight_smile:

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