Filter specific row from one data table to other data table

I am using Windows Application. I have two data tables called "dt1" and "dt2".

In "dt1" i have some rows like

ID Name Group
1  A1    G1
2  A2    G1
2  A2    G2
3  A3    G2
3  A3    G1
4  A4    G2
5  A5    G2 

AND In second table "dt2",

ID NAME  
1  A1
2  A2
3  A3
4  A4
5  A5
6  A6

Now i want rows of "dt2" from filtered row "dt1" say id - 1,2 which is also present in "dt2".

So basically i want rows for one data table from other data table which is filtered.

Can any one give some idea how to get this?

Answers


The most efficient and easiest would be to use Linq-To-DataSet and join both tables:

Dim result = From r1 In dt1.AsEnumerable()
             Join r2 In dt2.AsEnumerable()
             On r1.Field(Of Int32)("ID") Equals r2.Field(Of Int32)("ID")
             Select r2

If you want the result, what is an IEnumerable(Of DataRow), as DataTable:

Dim tblResult = result.CopyToDataTable()

Need Your Help

How to do Realtime/fast processing of GPS data in web application?

mysql django web-applications gps real-time

I am writing a web application for mapping Real-time GPS coordinates on Google maps coming from a GPS device, for fleet managment.

API module version

php php-extension

When I build a PHP module extension in C, how can I know the "short" version number of PHP I'm dealing with ? (5.4, 5.3, 5.2, 5.x, ...)

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.