tags:

views:

430

answers:

1

I have two datatables defined like this;

Dim db1, db2 As New DataTable

db1 and db2 hold results from different queries but the columns in both are exactly the same. I would like to create another datatable which consists of records that are in both db1 and db2. i.e I want the intersection of the two datatables. Is there an easy way to do this?

(The resultant datatable will be used to populate a gridview.)

A: 

If you are using VB.NET with LINQ you could do it like this:

Dim db3 = db1.Intersect(db2)

From there just use db3 to populate your GridView.

Venesectrix