Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Try It Out - Table Using EOF and a Counter - Page 11

November 27, 2000

Now we can improve on the last code listing by adding a numbering column and a note on the number of sailors at the bottom. Later we will learn the use of the recordcount property, but for now we will use a counter variable.

<%
dim oRSeofc
set oRSeofc=Server.createObject("ADODB.recordset")
oRSEOFc.Open "People", "DSN=sailors"
oRSeofc.MoveFirst
Response.Write "<TABLE BORDER='1'>"
Dim PersonCounter
PersonCounter = 0
Do while NOT oRSeofc.EOF
  PersonCounter =PersonCounter + 1
  Response.Write "<TR><TD>" & PersonCounter & "</TD>"
  Response.Write "<TD>" & oRSeofc("PeopleNameFirst") & "</TD>"
  Response.Write "<TD>" & oRSeofc("PeopleNameLast") & "</TD></TR>"
  oRSeofc.MoveNext
Loop
Response.Write "</TABLE><BR>"
Response.Write PersonCounter & " Sailors in this list"
 %>
Example 5

How it Works - Sailors Table with EOF an

The set up of the recordset is the same as the last code listing, but now we dim another variable for the purpose of keeping count of the people and initialize that to zero:

Dim PersonCounter
PersonCounter = 0
Now when we do our loops we start by increasing that PeopeCounter by 1 and printing that in its own cell. Then we finish off the row as before.
Do while NOT oRSeofc.EOF
  PersonCounter =PersonCounter + 1
  Response.Write "<TR><TD>" & PersonCounter & "</TD>"
  Response.Write "<TD>" & oRSeofc("PeopleNameFirst") & "</TD>"
  Response.Write "<TD>" & oRSeofc("PeopleNameLast") & "</TD></TR>"
  oRSeofc.MoveNext
Loop
Response.Write "</TABLE>"
%>

Try It Out - Table Using EOF - Page 10
Beginning ASP Databases
A Trap With Recordsets and Tables - Page 12


Up to => Home / Authoring / ASP / BeginningASPDatabases




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers