Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loops

Status
Not open for further replies.

JJ297

Programmer
Jun 27, 2007
30
0
0
US
Hi,

I'm a newbie to sql programming and need some assistance in trying to get Topics, questions and answers from a database.

I want Topics on one line, then the question that goes with that topic and answer on the lines underneath.

How do I code this? I'm grabbing the data with a data reader.

I was thinking of...

Dim topic

For each row in Me.table1.rows
If myreader(topic) = topic then
response.write topic


Any help will be appreciated. Thanks.
 
Code:
SELECT Topic on top line, Question under that line FROM somewhere

Given the details that's the best I can come up with aside from this not being SQL question

[sub]____________ signature below ______________
You are a amateur developer until you realize all your code sucks.
Jeff Atwood[/sub]
 
Thanks for your help but how do I loop through the records to show topic, questions and answers. Do I use a For each loop?
 
forum796

Yeah, one of those loopy thingy things

[sub]____________ signature below ______________
You are a amateur developer until you realize all your code sucks.
Jeff Atwood[/sub]
 
Bit grouchy today, are you Jeff? [smile]

297nina,

Jeff's point here is that SQL Server is not the appropriate place to do loops because it is ineffiencient. Instead, you should return the data and format it in your front end code.

-George

"the screen with the little boxes in the window." - Moron
 
:-( sorry, you're right. Apologies 297nina.

[sub]____________ signature below ______________
You are a amateur developer until you realize all your code sucks.
Jeff Atwood[/sub]
 
Thanks George,

Sorry for the inproper wording Jeff but as I said I'm new to this and don't know all of the lingo yet ;-).

Could you help me set up a for each loop to bring the topic out of the database with the appropiate question and answer that goes with it?

I'm using .NET and have a table displayed on the page and in the code behind I'm using a data reader.

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top