How do I merge tables in ado.net

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
 
B

Brian Lampe

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
 
P

PO

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
 
C

Cor Ligthert[MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top