Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > how to mix 2 recordsets into one result table?

Reply
Thread Tools

how to mix 2 recordsets into one result table?

 
 
AFN
Guest
Posts: n/a
 
      02-11-2004
Hi. I'm pretty comfortable binding a single recordset result to a
datagrid. But now I have a more unique problem. I have 2 really long
stored procedures that cannot be combined at the SQL Server level (please
don't ask why, but it can't, and even if I could, it would take 10x longer
because they are very involved queries). But I need to mix the recordset
results into one HTML table, and need advice about the best way to do that.
Example:

Table 1
PrimaryID BookName BookPrice
1 Alpha Book $14.00
2 Beta Book $5.00
3 Delta Book $7.00

Table2
ForeignKey BookName BookPrice
1 Animal Book $10.00
2 Mary's Cooking $12.99
2 Mary's Crafts $15.00
3 Fred's Biography $18.00

Desired HTML Table Results after merging the 2 tables, inserting each
matching record from table 2 into table 1, under the record from table 1:

Books For Sale:
Alpha Book $14.00
Animal Book $10.00
Beta Book $5.00
Mary's Cooking $12.99
Mary's Crafts $15.00
Delta Book $7.00
Fred's Biography $18.00


My thoughts? I'm thinking about different ways, and I have no idea what is
fastest, and I also don't want to try them all. For instance, I could get
the 2 recordsets, and then, with code, make my own array, and then bind that
array to a datagrid.

Your suggestions?


 
Reply With Quote
 
 
 
 
Michael Ramey
Guest
Posts: n/a
 
      02-11-2004
How about using DataAdapter to fill a DataSet twice, with each Command.
Then bind the Datagrid to the dataset.

--Michael

"AFN" <> wrote in message
news:QVtWb.885$...
> Hi. I'm pretty comfortable binding a single recordset result to a
> datagrid. But now I have a more unique problem. I have 2 really long
> stored procedures that cannot be combined at the SQL Server level (please
> don't ask why, but it can't, and even if I could, it would take 10x longer
> because they are very involved queries). But I need to mix the recordset
> results into one HTML table, and need advice about the best way to do

that.
> Example:
>
> Table 1
> PrimaryID BookName BookPrice
> 1 Alpha Book $14.00
> 2 Beta Book $5.00
> 3 Delta Book $7.00
>
> Table2
> ForeignKey BookName BookPrice
> 1 Animal Book $10.00
> 2 Mary's Cooking $12.99
> 2 Mary's Crafts $15.00
> 3 Fred's Biography $18.00
>
> Desired HTML Table Results after merging the 2 tables, inserting each
> matching record from table 2 into table 1, under the record from table 1:
>
> Books For Sale:
> Alpha Book $14.00
> Animal Book $10.00
> Beta Book $5.00
> Mary's Cooking $12.99
> Mary's Crafts $15.00
> Delta Book $7.00
> Fred's Biography $18.00
>
>
> My thoughts? I'm thinking about different ways, and I have no idea what

is
> fastest, and I also don't want to try them all. For instance, I could get
> the 2 recordsets, and then, with code, make my own array, and then bind

that
> array to a datagrid.
>
> Your suggestions?
>
>



 
Reply With Quote
 
 
 
 
AFN
Guest
Posts: n/a
 
      02-11-2004
but how would I intersperse the two recordsets into the right order in the
dataset?


"Michael Ramey" <raterus@localhost> wrote in message
news:...
> How about using DataAdapter to fill a DataSet twice, with each Command.
> Then bind the Datagrid to the dataset.
>
> --Michael
>
> "AFN" <> wrote in message
> news:QVtWb.885$...
> > Hi. I'm pretty comfortable binding a single recordset result to a
> > datagrid. But now I have a more unique problem. I have 2 really long
> > stored procedures that cannot be combined at the SQL Server level

(please
> > don't ask why, but it can't, and even if I could, it would take 10x

longer
> > because they are very involved queries). But I need to mix the

recordset
> > results into one HTML table, and need advice about the best way to do

> that.
> > Example:
> >
> > Table 1
> > PrimaryID BookName BookPrice
> > 1 Alpha Book $14.00
> > 2 Beta Book $5.00
> > 3 Delta Book $7.00
> >
> > Table2
> > ForeignKey BookName BookPrice
> > 1 Animal Book $10.00
> > 2 Mary's Cooking $12.99
> > 2 Mary's Crafts $15.00
> > 3 Fred's Biography $18.00
> >
> > Desired HTML Table Results after merging the 2 tables, inserting each
> > matching record from table 2 into table 1, under the record from table

1:
> >
> > Books For Sale:
> > Alpha Book $14.00
> > Animal Book $10.00
> > Beta Book $5.00
> > Mary's Cooking $12.99
> > Mary's Crafts $15.00
> > Delta Book $7.00
> > Fred's Biography $18.00
> >
> >
> > My thoughts? I'm thinking about different ways, and I have no idea

what
> is
> > fastest, and I also don't want to try them all. For instance, I could

get
> > the 2 recordsets, and then, with code, make my own array, and then bind

> that
> > array to a datagrid.
> >
> > Your suggestions?
> >
> >

>
>



 
Reply With Quote
 
Michael Ramey
Guest
Posts: n/a
 
      02-11-2004
Sort it?, or create a dataview from the dataset that is sorted the way you
like it.

"AFN" <> wrote in message
news:nnwWb.915$...
> but how would I intersperse the two recordsets into the right order in the
> dataset?
>
>
> "Michael Ramey" <raterus@localhost> wrote in message
> news:...
> > How about using DataAdapter to fill a DataSet twice, with each Command.
> > Then bind the Datagrid to the dataset.
> >
> > --Michael
> >
> > "AFN" <> wrote in message
> > news:QVtWb.885$...
> > > Hi. I'm pretty comfortable binding a single recordset result to a
> > > datagrid. But now I have a more unique problem. I have 2 really

long
> > > stored procedures that cannot be combined at the SQL Server level

> (please
> > > don't ask why, but it can't, and even if I could, it would take 10x

> longer
> > > because they are very involved queries). But I need to mix the

> recordset
> > > results into one HTML table, and need advice about the best way to do

> > that.
> > > Example:
> > >
> > > Table 1
> > > PrimaryID BookName BookPrice
> > > 1 Alpha Book $14.00
> > > 2 Beta Book $5.00
> > > 3 Delta Book $7.00
> > >
> > > Table2
> > > ForeignKey BookName BookPrice
> > > 1 Animal Book $10.00
> > > 2 Mary's Cooking $12.99
> > > 2 Mary's Crafts $15.00
> > > 3 Fred's Biography $18.00
> > >
> > > Desired HTML Table Results after merging the 2 tables, inserting each
> > > matching record from table 2 into table 1, under the record from table

> 1:
> > >
> > > Books For Sale:
> > > Alpha Book $14.00
> > > Animal Book $10.00
> > > Beta Book $5.00
> > > Mary's Cooking $12.99
> > > Mary's Crafts $15.00
> > > Delta Book $7.00
> > > Fred's Biography $18.00
> > >
> > >
> > > My thoughts? I'm thinking about different ways, and I have no idea

> what
> > is
> > > fastest, and I also don't want to try them all. For instance, I could

> get
> > > the 2 recordsets, and then, with code, make my own array, and then

bind
> > that
> > > array to a datagrid.
> > >
> > > Your suggestions?
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
AFN
Guest
Posts: n/a
 
      02-11-2004
if you look at my example, there is no way to sort it. the records with the
same IDs from recordset 1 must show before the records from recordset 2 with
those same IDs.


"Michael Ramey" <raterus@localhost> wrote in message
news:...
> Sort it?, or create a dataview from the dataset that is sorted the way you
> like it.
>
> "AFN" <> wrote in message
> news:nnwWb.915$...
> > but how would I intersperse the two recordsets into the right order in

the
> > dataset?
> >
> >
> > "Michael Ramey" <raterus@localhost> wrote in message
> > news:...
> > > How about using DataAdapter to fill a DataSet twice, with each

Command.
> > > Then bind the Datagrid to the dataset.
> > >
> > > --Michael
> > >
> > > "AFN" <> wrote in message
> > > news:QVtWb.885$...
> > > > Hi. I'm pretty comfortable binding a single recordset result to a
> > > > datagrid. But now I have a more unique problem. I have 2 really

> long
> > > > stored procedures that cannot be combined at the SQL Server level

> > (please
> > > > don't ask why, but it can't, and even if I could, it would take 10x

> > longer
> > > > because they are very involved queries). But I need to mix the

> > recordset
> > > > results into one HTML table, and need advice about the best way to

do
> > > that.
> > > > Example:
> > > >
> > > > Table 1
> > > > PrimaryID BookName BookPrice
> > > > 1 Alpha Book $14.00
> > > > 2 Beta Book $5.00
> > > > 3 Delta Book $7.00
> > > >
> > > > Table2
> > > > ForeignKey BookName BookPrice
> > > > 1 Animal Book $10.00
> > > > 2 Mary's Cooking $12.99
> > > > 2 Mary's Crafts $15.00
> > > > 3 Fred's Biography $18.00
> > > >
> > > > Desired HTML Table Results after merging the 2 tables, inserting

each
> > > > matching record from table 2 into table 1, under the record from

table
> > 1:
> > > >
> > > > Books For Sale:
> > > > Alpha Book $14.00
> > > > Animal Book $10.00
> > > > Beta Book $5.00
> > > > Mary's Cooking $12.99
> > > > Mary's Crafts $15.00
> > > > Delta Book $7.00
> > > > Fred's Biography $18.00
> > > >
> > > >
> > > > My thoughts? I'm thinking about different ways, and I have no idea

> > what
> > > is
> > > > fastest, and I also don't want to try them all. For instance, I

could
> > get
> > > > the 2 recordsets, and then, with code, make my own array, and then

> bind
> > > that
> > > > array to a datagrid.
> > > >
> > > > Your suggestions?
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
dilipdotnet at apdiya.com
Guest
Posts: n/a
 
      02-11-2004
How about making the sps return an additional column indicating the
source in the order you wanted it...

so for example you could return

ForeignKey BookName BookPrice TableNo.

Then you could sort on Foreignkey, TableNo.

Let me know if that works

AFN wrote:

> if you look at my example, there is no way to sort it. the records with the
> same IDs from recordset 1 must show before the records from recordset 2 with
> those same IDs.
>
>
> "Michael Ramey" <raterus@localhost> wrote in message
> news:...
>
>>Sort it?, or create a dataview from the dataset that is sorted the way you
>>like it.
>>
>>"AFN" <> wrote in message
>>news:nnwWb.915$...
>>
>>>but how would I intersperse the two recordsets into the right order in

>
> the
>
>>>dataset?
>>>
>>>
>>>"Michael Ramey" <raterus@localhost> wrote in message
>>>news:...
>>>
>>>>How about using DataAdapter to fill a DataSet twice, with each

>
> Command.
>
>>>>Then bind the Datagrid to the dataset.
>>>>
>>>>--Michael
>>>>
>>>>"AFN" <> wrote in message
>>>>news:QVtWb.885$. ..
>>>>
>>>>>Hi. I'm pretty comfortable binding a single recordset result to a
>>>>>datagrid. But now I have a more unique problem. I have 2 really

>>
>>long
>>
>>>>>stored procedures that cannot be combined at the SQL Server level
>>>
>>>(please
>>>
>>>>>don't ask why, but it can't, and even if I could, it would take 10x
>>>
>>>longer
>>>
>>>>>because they are very involved queries). But I need to mix the
>>>
>>>recordset
>>>
>>>>>results into one HTML table, and need advice about the best way to

>
> do
>
>>>>that.
>>>>
>>>>>Example:
>>>>>
>>>>>Table 1
>>>>>PrimaryID BookName BookPrice
>>>>>1 Alpha Book $14.00
>>>>>2 Beta Book $5.00
>>>>>3 Delta Book $7.00
>>>>>
>>>>>Table2
>>>>>ForeignKey BookName BookPrice
>>>>>1 Animal Book $10.00
>>>>>2 Mary's Cooking $12.99
>>>>>2 Mary's Crafts $15.00
>>>>>3 Fred's Biography $18.00
>>>>>
>>>>>Desired HTML Table Results after merging the 2 tables, inserting

>
> each
>
>>>>>matching record from table 2 into table 1, under the record from

>
> table
>
>>>1:
>>>
>>>>>Books For Sale:
>>>>>Alpha Book $14.00
>>>>>Animal Book $10.00
>>>>>Beta Book $5.00
>>>>>Mary's Cooking $12.99
>>>>>Mary's Crafts $15.00
>>>>>Delta Book $7.00
>>>>>Fred's Biography $18.00
>>>>>
>>>>>
>>>>>My thoughts? I'm thinking about different ways, and I have no idea
>>>
>>>what
>>>
>>>>is
>>>>
>>>>>fastest, and I also don't want to try them all. For instance, I

>
> could
>
>>>get
>>>
>>>>>the 2 recordsets, and then, with code, make my own array, and then

>>
>>bind
>>
>>>>that
>>>>
>>>>>array to a datagrid.
>>>>>
>>>>>Your suggestions?
>>>>>
>>>>>
>>>>
>>>>
>>>

>>

>
>


--
Regards,
Dilip Krishnan
MCAD, MCSD.net
dilipdotnet at apdiya dot com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mix different C source files into a single one Horacius ReX C Programming 6 12-30-2007 08:06 AM
Mix different C source files into a single one Horacius ReX Python 4 12-29-2007 10:02 PM
How to mix 5.1 channels into one audio stream ? boardrider DVD Video 0 09-07-2005 08:02 AM
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM
Q: About how/where to store RecordSets in UserControls? Sky ASP .Net 2 03-04-2004 10:13 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57