473,503 Members | 10,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looking for an example

I'm trying to display multiple resultsets, returned in a SQLDataReader, in a
single table. The number of resultsets returned is variable, usually 3 or 4.
Basically, each resultset has 1 row and I'd like to display each row as a
row in the same table. I'd like to use the DataGrid if possible.

Here is my original idea:
1. Get returned DataReader
2. For each DataSet returned, create a DataGrid control, populate and
display
a. First DataGrid will have a header showing column names
b. Following DataGrids will have no header

Any ideas or places I can do more reading?

Thanks,

Mike
Nov 17 '05 #1
4 1261
Thus spake M. Craig:
Any ideas or places I can do more reading?


Is it not possible to use a single query to pull all the rows at once?
If not, you can use a DataAdapter to repeatedly fill a DataSet so long
as your selections come from the same table.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
Nov 17 '05 #2
I would investigate the UNION query to create a single rowset on the server.
This would simplify the server-side of the operation as well as make it easy
to use the Fill method to construct the DataTable. I don't use the
DataReader to construct DataTable objects--it's too slow when compared with
Fill. The DataTable can be bound to the DataGrid quite easily.

hth

--
____________________________________
Bill Vaughn
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
"M. Craig" <mc****@pugetsoundmicro.com> wrote in message
news:eH**************@TK2MSFTNGP12.phx.gbl...
I'm trying to display multiple resultsets, returned in a SQLDataReader, in a single table. The number of resultsets returned is variable, usually 3 or 4. Basically, each resultset has 1 row and I'd like to display each row as a
row in the same table. I'd like to use the DataGrid if possible.

Here is my original idea:
1. Get returned DataReader
2. For each DataSet returned, create a DataGrid control, populate and
display
a. First DataGrid will have a header showing column names
b. Following DataGrids will have no header

Any ideas or places I can do more reading?

Thanks,

Mike

Nov 17 '05 #3
Thanks all for your suggestions.
I couldn't figure out how to do a UNION for this, but I came across an
article suggesting using #TempTables, which I thought was a GRAND idea.
Here is what I finished up with. If anyone would care to reword this Stored
Proc into something better, I'd be very appreciative!

Thanks again.

--Here's the result:
Promotion State Build Label
Date Started
-------------------------------------------------- -------------------------
------------------------- ------------
QA 01 corm_01_09_01_999
Sep 20 2003
Prod corm_01_09_01_001
Sep 8 2003

--And here is the query:

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER procedure usp_GetBuildSummaryByCompId2
@CompID int =5

as

declare @EnvName varchar(25)
declare @EnvID int

declare Environments_Cursor CURSOR FOR

-- Create Temp table to hold Build Summary results

select e.EnvName , e.EnvironmentID from _ProductEnvironments pe
join _Environments e on pe.EnvironmentID = e.EnvironmentID
where CompID=5
order by LayerOrder

OPEN Environments_Cursor

--Do first Fetch
FETCH NEXT FROM Environments_Cursor
INTO @EnvName, @EnvID

-- Do first query to set up table
select top 1 e.EnvName as 'Promotion State', pb.BuildLabel as 'Build Label',
CONVERT(char(12), bp.PromotionDate) as 'Date Started' into #TempTable
from _products p
join _ProductComponents pc on p.ProductID = pc.ProductID
join _ProductBuilds pb on pc.CompID = pb.CompID
join _BuildPromotions bp on pb.BuildID = bp.BuildID
join _ProductEnvironments pe on bp.ProdEnvID = pe.ProdEnvID
join _Environments e on pe.EnvironmentID = e.EnvironmentID
where pc.CompID = @CompID and e.EnvironmentID= @EnvID
order by PromotionDate Desc

-- Get next Fetch
FETCH NEXT FROM Environments_Cursor
INTO @EnvName, @EnvID

-- Check Fetch status to see if there are more rows avail.
WHILE @@FETCH_STATUS = 0
BEGIN

-- Find out the build details for each layer
Insert Into #TempTable
select top 1 e.EnvName as 'Promotion State', pb.BuildLabel as 'Build
Label', CONVERT(char(12), bp.PromotionDate) as 'Date Started'
from _products p
join _ProductComponents pc on p.ProductID = pc.ProductID
join _ProductBuilds pb on pc.CompID = pb.CompID
join _BuildPromotions bp on pb.BuildID = bp.BuildID
join _ProductEnvironments pe on bp.ProdEnvID = pe.ProdEnvID
join _Environments e on pe.EnvironmentID = e.EnvironmentID
where pc.CompID = @CompID and e.EnvironmentID= @EnvID
order by PromotionDate Desc

-- Get Next EnvID
FETCH NEXT FROM Environments_Cursor
INTO @EnvName, @EnvID

END
select * from #TempTable
-- Close Cursor and clean up
CLOSE Environments_Cursor
DEALLOCATE Environments_Cursor
drop table #TempTable

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

"William (Bill) Vaughn" <No***************@nwlink.com> wrote in message
news:uf*************@TK2MSFTNGP11.phx.gbl...
I would investigate the UNION query to create a single rowset on the server. This would simplify the server-side of the operation as well as make it easy to use the Fill method to construct the DataTable. I don't use the
DataReader to construct DataTable objects--it's too slow when compared with Fill. The DataTable can be bound to the DataGrid quite easily.

hth

--
____________________________________
Bill Vaughn
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights. __________________________________
"M. Craig" <mc****@pugetsoundmicro.com> wrote in message
news:eH**************@TK2MSFTNGP12.phx.gbl...
I'm trying to display multiple resultsets, returned in a SQLDataReader, in
a
single table. The number of resultsets returned is variable, usually 3
or 4.
Basically, each resultset has 1 row and I'd like to display each row as

a row in the same table. I'd like to use the DataGrid if possible.

Here is my original idea:
1. Get returned DataReader
2. For each DataSet returned, create a DataGrid control, populate and display
a. First DataGrid will have a header showing column names
b. Following DataGrids will have no header

Any ideas or places I can do more reading?

Thanks,

Mike


Nov 17 '05 #4
I couldn't figure out how to do this with one SQL Query, but I still wanted
to do most of the crunching on the SQL Server end of things.

See my reply to Bill Vaughn for what I came up with.

Thanks though,

Mike

"Frank Oquendo" <fr****@acadx.com> wrote in message
news:eb**************@tk2msftngp13.phx.gbl...
Thus spake M. Craig:
Any ideas or places I can do more reading?


Is it not possible to use a single query to pull all the rows at once?
If not, you can use a DataAdapter to repeatedly fill a DataSet so long
as your selections come from the same table.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com

Nov 17 '05 #5

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

Similar topics

14
1698
by: Marco Aschwanden | last post by:
Hi I would like to develop an app that is (more or less) database independet. Python DB API helps when masking "parameters" of sql statements. The db driver cares for the correct conversion of a...
4
3573
by: Frank Einstein | last post by:
Looking for a tool that can edit an XML file in a browser. The basic requirement is that the XML file is rendered as an HTML form with editable fields (including add/delete, preferably in...
3
1207
by: SpamProof | last post by:
I'm looking for an example of a detailed design that I can follow or get ideas from before programming in vb.net. Currently, I'm using this outline approach that describes my Project, Classes,...
3
6796
by: MikeY | last post by:
Hi Everyone, I am working in C#, windows forms.My question is this. All my button dynamic controls properties are present and accounted for except for the"FlatStyle" properties. I can't seem to...
0
1715
by: pepsi | last post by:
Hello, I would suggest a simple div tag... you could assign it a id and runat server. It should work. pepsi >-----Original Message----- >Hi gang. I tried posting this under a different...
0
2720
by: Gene Ariani | last post by:
Hi; I am looking for 3-tier web examples for .Net environment. Most examples treat the code as they are residing on the same machine. I am looking for an example that treats 3-tier as client,...
6
7268
by: Bosconian | last post by:
I'm looking to reproduce the div popup behavior like vBulletin's search link: http://www.vbulletin.com/forum/ I've looked at many examples, but most are complicated and/or convoluted menu...
13
3085
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
11
2332
by: matsi.inc | last post by:
I am looking to make something like a delegate that i can use in my projects but am having a hard time getting started. The behavior I am most interested in is how a delegate changes it's Invoke...
3
1225
by: Paul | last post by:
Looking for recommendations on a programming language for a web application. I am soliciting recommendations on a programming language for a web application described below. Actually, it is not...
0
7095
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7361
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7015
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...
0
5602
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,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3183
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...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1523
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 ...
0
403
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...

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.