No, you can't make a simple sql query for that. You could write a stored
procedure, but it is much easier just to do it in the code with a while
loop, as you say. A good place for this is PreRender event for the control
you use for rendering the data (GridView, repeater, etc). In this event the
control is already fully built and you can loop through the Items
collection.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
<de*******@yahoo.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Exactly! But I'm having trouble writing the SQL code for this. Also,
this kind of model wouldn't work well with DataReader, since it read
one row at a time.
Would a DataSet be better here? (easier, perhaps?)
Eliyahu Goldin wrote:
>Like this?
1 a1
a2
a3
a4
2 a1
a2
a3
a4
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
<de*******@yahoo.comwrote in message
news:11**********************@d34g2000cwd.googleg roups.com...
>I simply want to output 4 answers for every question without repeating
the question.
(with a datareader if possible)
Eliyahu Goldin wrote:
Give an example of what you would like to see in the result record
set.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
<de*******@yahoo.comwrote in message
news:11**********************@b28g2000cwb.googleg roups.com...
This is the result of a JOINed query:
question answer
1 a1
1 a2
1 a3
1 a4
2 a1
2 a2
2 a3
2 a4
How would I use a DataReader to output this data without repeating
each
question 4 times?
Do I weed out the repeated question in C# with a while loop?
Or is there a way to do this in the SQL statement?
Thank you for your time and help!