473,566 Members | 3,091 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to mix 2 recordsets into one result table?

AFN
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?
Nov 18 '05 #1
5 1371
How about using DataAdapter to fill a DataSet twice, with each Command.
Then bind the Datagrid to the dataset.

--Michael

"AFN" <DE************ ************@ya hoo.com> wrote in message
news:QV******** *******@twister .socal.rr.com.. .
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?

Nov 18 '05 #2
AFN
but how would I intersperse the two recordsets into the right order in the
dataset?
"Michael Ramey" <raterus@localh ost> wrote in message
news:u3******** ******@TK2MSFTN GP10.phx.gbl...
How about using DataAdapter to fill a DataSet twice, with each Command.
Then bind the Datagrid to the dataset.

--Michael

"AFN" <DE************ ************@ya hoo.com> wrote in message
news:QV******** *******@twister .socal.rr.com.. .
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?


Nov 18 '05 #3
Sort it?, or create a dataview from the dataset that is sorted the way you
like it.

"AFN" <DE************ ************@ya hoo.com> wrote in message
news:nn******** *******@twister .socal.rr.com.. .
but how would I intersperse the two recordsets into the right order in the
dataset?
"Michael Ramey" <raterus@localh ost> wrote in message
news:u3******** ******@TK2MSFTN GP10.phx.gbl...
How about using DataAdapter to fill a DataSet twice, with each Command.
Then bind the Datagrid to the dataset.

--Michael

"AFN" <DE************ ************@ya hoo.com> wrote in message
news:QV******** *******@twister .socal.rr.com.. .
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?



Nov 18 '05 #4
AFN
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@localh ost> wrote in message
news:u2******** ******@TK2MSFTN GP11.phx.gbl...
Sort it?, or create a dataview from the dataset that is sorted the way you
like it.

"AFN" <DE************ ************@ya hoo.com> wrote in message
news:nn******** *******@twister .socal.rr.com.. .
but how would I intersperse the two recordsets into the right order in the
dataset?
"Michael Ramey" <raterus@localh ost> wrote in message
news:u3******** ******@TK2MSFTN GP10.phx.gbl...
How about using DataAdapter to fill a DataSet twice, with each Command. Then bind the Datagrid to the dataset.

--Michael

"AFN" <DE************ ************@ya hoo.com> wrote in message
news:QV******** *******@twister .socal.rr.com.. .
> 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?
>
>



Nov 18 '05 #5
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@localh ost> wrote in message
news:u2******** ******@TK2MSFTN GP11.phx.gbl...
Sort it?, or create a dataview from the dataset that is sorted the way you
like it.

"AFN" <DE************ ************@ya hoo.com> wrote in message
news:nn****** *********@twist er.socal.rr.com ...
but how would I intersperse the two recordsets into the right order in
the
dataset?
"Michael Ramey" <raterus@localh ost> wrote in message
news:u3***** *********@TK2MS FTNGP10.phx.gbl ...

How about using DataAdapter to fill a DataSet twice, with each
Command.
Then bind the Datagrid to the dataset.

--Michael

"AFN" <DE************ ************@ya hoo.com> wrote in message
news:QV**** ***********@twi ster.socal.rr.c om...

>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
>PrimaryI D BookName BookPrice
>1 Alpha Book $14.00
>2 Beta Book $5.00
>3 Delta Book $7.00
>
>Table2
>ForeignK ey 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
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1584
by: Steve Marciniak | last post by:
I'm trying to display different recordsets (which are 1 field each) as columns right next to one another. For example, Recordset1 is displayed on the left hand side of the screen. Recordset2 is displayed immediately to the right of then first recordset with the first rows or each at the same level. Recordset3 is displayed to the right of...
1
2706
by: Sascha | last post by:
Hi I need some help on achieving the following: I wrote a querie which collects Data out of three Tables, the Result looks like this: SET NOCOUNT ON DECLARE @ROW INT
2
1758
by: Pieter Linden | last post by:
The answer to this one is probably "test it yourself and find out!", but I'll ask anyway. Pursuant to my previous question - sending separate recordsets to Word using the CreateTableFromRecordset code from ADH2000... I will be opening like 8 recordsets {one for each building, and there are 8). Would I be better off or is there anything to...
16
5709
by: Randy Harris | last post by:
I was inspired by the recent discussion of returning multiple recordsets to ADO from a stored procedure. (Amazed is probably more accurate). I asked about how to accomplish same with Oracle and got a nudge in the right direction from Mr. Kreft. I promised to provide details once working, so here it is. The code is shown below. My next...
34
10785
by: Jeff | last post by:
For years I have been using VBA extensively for updating data to tables after processing. By this I mean if I had to do some intensive processing that resulted in data in temp tables, I would have VBA code that wrote the results of that away to the db, either creating new records or updating existing records, whichever was relevant. This may...
24
8471
by: Donald Grove | last post by:
I want to populate an array with values from an ado recordset (multiple rows) I use the absolute position of the cursor in the recordset to define the row of my array to be populated. I have a workaround for lack of a way to define the ordinal position of a field (incrementing a counter variable), but it feels so primitive: dim Fld as...
12
2229
convexcube
by: convexcube | last post by:
Hi Experts, I have a unbound form which records details of complaints. It also records what products are affected in the complaint. These are stored in a table named ComplaintProducts that has the fields: ComplaintProductsIndex (Autonumber), ComplaintIndex & ProductName. The product list is quite lengthy, so I have set up a separate form...
3
10022
by: Dooza | last post by:
Hi there, I have a Stored Procedure in SQL 2000 that takes 10 input paremeters, and outputs 11 recordsets, not rows, but 11 different SELECT statements. The purpose of this is to for a menu system in a store. If all the inputs are NULL, then just the top level categories are output in the first recordset. The ID of each category will then...
11
3115
by: BeckR | last post by:
Hello - Thanks for reading my post. I am a newbie when it comes to VBA programming, but have managed to do what I need to do, until now. I have an Access 2000 database (running WinXP Pro (SP3)). I have successfully created 3 recordsets in my database. What I need to do is to take the data from those 3 recordsets and put them into a...
0
7683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7899
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7649
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6270
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3647
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3628
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1204
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
927
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.