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

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

new
European Travel
Action Movies
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel


dailyclick
All times in EST

Autism Spectrum Disorders: 4:00 PM

Full Schedule
g
g ASP Site

BellaOnline's ASP Editor

g

Selecting All Rows from a Table


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.
Add Selecting+All+Rows+from+a+Table to Twitter Add Selecting+All+Rows+from+a+Table to Facebook Add Selecting+All+Rows+from+a+Table to MySpace Add Selecting+All+Rows+from+a+Table to Del.icio.us Digg Selecting+All+Rows+from+a+Table Add Selecting+All+Rows+from+a+Table to Yahoo My Web Add Selecting+All+Rows+from+a+Table to Google Bookmarks Add Selecting+All+Rows+from+a+Table to Stumbleupon Add Selecting+All+Rows+from+a+Table to Reddit




RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


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


Content copyright © 2014 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 Lisa Shea for details.

g


g features
Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


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


BellaOnline Editor