logo
g Text Version
Auto
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Society & Culture
Sports
Travel & Leisure
TV & Movies

dailyclick
Bored? Games!
Postcards
Astrology
Take a Quiz
Rate My Photo

new
Jokes & Riddles
Astronomy
Philosophy
Public Health
Canadian Culture


dailyclick
All times in EST

Full Schedule
g
g ASP Site
Editor Wanted
BellaOnline's ASP Editor

g

Selecting All Rows from a Table
Guest Author - Lisa Shea

There are many times that you will want to select all rows from a given database table. How do you move through the records, and display the data?

Let's say you have a table with BookName as a field and you want to write to the screen all BookNames in your library. You would start with -

Set BookList = Server.CreateObject ("ADODB.Recordset")
SQLText = "select BookName from Books order by BookName"
BookList.Open SQLText, strConnect, adOpenForwardOnly, adLockReadOnly, adCmdText
do while not BookList.EOF
response.write BookList("BookName") & "
"
BookList.MoveNext()
loop
BookList.Close()
Set BookList = Nothing

The critical part of this code is the MoveNext. That tells the database to move on to the next record. If you did NOT include the MoveNext command, the system would just keep printing out the first book's title - over and over again - until it maxed out your system's resources! This is something to pay really close attention to.

Note that your select statement can of course have a "WHERE" clause in it. You can select all books that are over 19.99 in price, or all books added in the past week. This do loop will then loop through every row in the result set, and show them to the end user.

This site needs an editor - click to learn more!

RSS | Related Articles | Previous Features | Site Map


Content copyright © 2008 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

Digg! g delicious Save to Del.icio.us

g


For FREE email updates, subscribe to the ASP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor

g features
Best uses for RSS

RSS and its future.

Force Download Dialog box with ASP

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Driving Amount
Much more
Slightly more
Slightly less
Much less

g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2008 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor