Lookup Multiple Datatables into 1 datatable
dt1
Code:
ID Animal
1 Monkey
2 Cat
3 Dog
4 Fish
dt2
Code:
ID Activity
1 Walk
2 Swim
3 Climb
dtMain
Code:
ID Animal Activity Comment
1 1 3 Blah blah
2 4 2 foobar
I want to display....
Code:
ID Animal Activity Comment
1 Monkey Climb Blah blah
2 Fish Swim foobar
Hi there,
I have a problem here, not sure how to tackle this one. I have a datatable (dtMain) which has columns which I want to replace the values in a datatable with the descriptor of the lookup tables.
Anyone have any ideas at all? Is it even possible?
Many many thanks in advance!
Re: Lookup Multiple Datatables into 1 datatable
Would it not be better to just execute a query against the database and get the data in the format you want it in the first place? If not, you can perform a LINQ query to join the data in the two DataTables and then call CopyToDataTable to create a new DataTable containing the results.
Re: Lookup Multiple Datatables into 1 datatable
Quote:
Originally Posted by
jmcilhinney
Would it not be better to just execute a query against the database and get the data in the format you want it in the first place? If not, you can perform a LINQ query to join the data in the two DataTables and then call CopyToDataTable to create a new DataTable containing the results.
I agree, making one query with proper joins will save you a lot of trouble later.
If they're in different databases, you can always use a DB link