Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Good Day to All!
How can I join 2 datatables which contains data imported from excel?
I've tried using Merge() but it doesn't give my desired result.

Here is my code:
VB
oleTable3 = New DataTable
oleTable3.Merge(oleTable1)
oleTable3.Merge(oleTable2)
dgvCompile.DataSource = oleTable3


<img src="http://i.imgur.com/ImeZLgf.jpg" title="source: imgur.com" />

As you can see, I use Merge() to get this result, but it only merge the "Batch Name" column from the 2 tables.

My desired result is something like this:
<img src="http://i.imgur.com/NaAKGea.jpg" title="source: imgur.com" />

The data that have same "Batch Name" will be in 1 row.

Any help will be appreciated!
Posted

1 solution

One easy way is to use LINQ to join the data. Have a look at the examples over here:
Query Expression Syntax Examples: Join Operators (LINQ to DataSet)[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900