|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How do I merge tables in ado.netHi,
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
Show quote
On Oct 18, 6:24 am, "PO" <h> wrote: If by "merge", you mean do a JOIN like INNER or LEFT JOIN, I believe> 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 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 Show quote "Brian Lampe" <gr8br***@gmail.com> skrev i meddelandet news:1192741414.556270.14240@q5g2000prf.googlegroups.com... > On Oct 18, 6:24 am, "PO" <h> wrote: >> 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 > > > > 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 Try the assembly at
http://www.queryadataset.com/documentation/merge-command.aspx. It supports a MERGE statement against tables in a DataSet. Its the same functionality and syntax as supported in the upcoming SQL-Server 2008. Download a trial version for .NET 1.1 or .NET 2.0/3.0 here: http://www.queryadataset.com/download.aspx Hope this helps Adrian Moore. http://www.queryadataset.com Show quote "PO" <h> wrote in message news:%239MLHpYEIHA.4544@TK2MSFTNGP06.phx.gbl... > 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 > Try the assembly at
http://www.queryadataset.com/documentation/merge-command.aspx. It supports a MERGE statement against tables in a DataSet. Its the same functionality and syntax as supported in the upcoming SQL-Server 2008. Download a trial version for .NET 1.1 or .NET 2.0/3.0 here: http://www.queryadataset.com/download.aspx Hope this helps Adrian Moore. http://www.queryadataset.com |
|||||||||||||||||||||||