How do I merge tables in ado.net

  • Thread starter Thread starter PO
  • Start date Start date
P

PO

Hi,

I'm fairly new to ado.net and I'm not sure I'm doing this in the best way...
I retrieve two tables from two different databases and place them in a
dataset. Both tables have a column which relates them. The relation type is
one to many.

I use a custom procedure to "merge" the two tables into a third before I
display the third table in a datagrid. The procedure creates a new table and
iterates through the two tables using a relation object and GetChildRows.

Is this how it should be done or is there a built in function that can do
the work for me?

Regards
Pete
 
Hi,

I'm fairly new to ado.net and I'm not sure I'm doing this in the best way...
I retrieve two tables from two different databases and place them in a
dataset. Both tables have a column which relates them. The relation type is
one to many.

I use a custom procedure to "merge" the two tables into a third before I
display the third table in a datagrid. The procedure creates a new table and
iterates through the two tables using a relation object and GetChildRows.

Is this how it should be done or is there a built in function that can do
the work for me?

Regards
Pete

If by "merge", you mean do a JOIN like INNER or LEFT JOIN, I believe
you are right.

Check this out: http://support.microsoft.com/kb/326080
 
Yes, sorry, I ment JOIN not MERGE.
The two tables have different columns and data except for one column which I
use to join them.

The kb article contains all the info I need - thanks!

Regards
Pete
 
PO,

In the way as you in my idea described it.

A windowforms datagrid (not a web one or a datagridview) can hold related
tables by just setting the datasource direct to the dataset without a
datamember.

I don't find it nice looking. As you want to make flat rows from it before,
then I would do it in the same way you wrote or select them in a flat way
direct by the Sql script Select by joining the tables in whatever way.
However I did not have the idea that it was what you asked.

Cor
 
Back
Top