Combining Recordsets

Combining Recordsets

Post by J » Fri, 20 Sep 2002 01:29:27



I need some help on combing record sets from different tables.  I can get
the info I need from the db from 2 separate tables.  I then want to combine
both separate recordsets into one single recordset so I can then display the
new single recordset in the data grid for end user selection.  Any help
would be greatly appreciated.

Thanks!

--
J

 
 
 

Combining Recordsets

Post by Val Mazu » Fri, 20 Sep 2002 01:56:15


Hi,

There is no simple way to merge recordsets into one. ADO does not have such
kind of functionality (ADO.NET has it). What you could do is to retieve one
recordset from two tables. You could do that using UNION statement between
your SELECT SQL statements

SELECT * FROM Table1...
UNINON
SELECT * FROM Table2 ....

If you cannot use that way,  then you would need to loop through recordsets
and add records from one recordset to another one one-by-one

--
Val Mazur
Microsoft MVP


Quote:> I need some help on combing record sets from different tables.  I can get
> the info I need from the db from 2 separate tables.  I then want to
combine
> both separate recordsets into one single recordset so I can then display
the
> new single recordset in the data grid for end user selection.  Any help
> would be greatly appreciated.

> Thanks!

> --
> J


 
 
 

Combining Recordsets

Post by J » Fri, 20 Sep 2002 02:07:06


I don't think the UNION will work in this instance.  Since one piece of
information from table one is required in order to get the rest of the
information from table 2.

J


> Hi,

> There is no simple way to merge recordsets into one. ADO does not have
such
> kind of functionality (ADO.NET has it). What you could do is to retieve
one
> recordset from two tables. You could do that using UNION statement between
> your SELECT SQL statements

> SELECT * FROM Table1...
> UNINON
> SELECT * FROM Table2 ....

> If you cannot use that way,  then you would need to loop through
recordsets
> and add records from one recordset to another one one-by-one

> --
> Val Mazur
> Microsoft MVP



> > I need some help on combing record sets from different tables.  I can
get
> > the info I need from the db from 2 separate tables.  I then want to
> combine
> > both separate recordsets into one single recordset so I can then display
> the
> > new single recordset in the data grid for end user selection.  Any help
> > would be greatly appreciated.

> > Thanks!

> > --
> > J

 
 
 

Combining Recordsets

Post by Val Mazu » Fri, 20 Sep 2002 02:18:34


So,  probably you would need to loop, or to use stored procedure, which will
do all that staff on server side and return result set as a one set

--
Val Mazur
Microsoft MVP


> I don't think the UNION will work in this instance.  Since one piece of
> information from table one is required in order to get the rest of the
> information from table 2.

> J



> > Hi,

> > There is no simple way to merge recordsets into one. ADO does not have
> such
> > kind of functionality (ADO.NET has it). What you could do is to retieve
> one
> > recordset from two tables. You could do that using UNION statement
between
> > your SELECT SQL statements

> > SELECT * FROM Table1...
> > UNINON
> > SELECT * FROM Table2 ....

> > If you cannot use that way,  then you would need to loop through
> recordsets
> > and add records from one recordset to another one one-by-one

> > --
> > Val Mazur
> > Microsoft MVP



> > > I need some help on combing record sets from different tables.  I can
> get
> > > the info I need from the db from 2 separate tables.  I then want to
> > combine
> > > both separate recordsets into one single recordset so I can then
display
> > the
> > > new single recordset in the data grid for end user selection.  Any
help
> > > would be greatly appreciated.

> > > Thanks!

> > > --
> > > J