Wrox Programmer Forums
|
Classic ASP Components Discussions specific to components in ASP 3.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 20th, 2004, 03:38 PM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to drumph Send a message via Yahoo to drumph
Default Recordset numbering

I have a recordset that is being displayed in a table and I wanted the displayed entries to be numbered as they are shown..
ex.
count firstname lastname
  1 henry jones
  2 mike jones

I thought the count portion would be easy but it seems to be an issue.. how can I generate a count and have it displayed in the returned HTML code?

Please advise.

 
Old May 20th, 2004, 05:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

You need to increment a variable!

Assuming your code looks somewhat like this...
Code:
Do While Not rs.eof
   response.write "<tr><td>" & rs("firstname") & "</td><td>" & rs("lastname") & "</td></tr>"
rs.MoveNext
Loop
...you'll want to increment a counter within the loop like this:
Code:
Do While Not rs.eof
   iRowCounter = iRowCounter + 1
   response.write "<tr><td>" & iRowCounter & "</td><td>" & rs("firstname") & "</td><td>" & rs("lastname") & "</td></tr>"
rs.MoveNext
Loop
HTH

~Jonax
 
Old May 20th, 2004, 06:14 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

The suggested method:

Do While Not rs.eof
   iRowCounter = iRowCounter + 1
   response.write "<tr><td>" & iRowCounter & "</td><td>" & rs("firstname") & "</td><td>" & rs("lastname") & "</td></tr>"
rs.MoveNext
Loop

Should be changed to:

dim iRowCounter (declaire your variable)
iRowCounter = 0 (set your variable to 0 and an integer (best practice))
Do While Not rs.eof
   iRowCounter = iRowCounter + 1
   response.write "<tr><td>" & iRowCounter & "</td><td>'" & rs("firstname") & "'</td><td>'" & rs("lastname") & "'</td></tr>"
rs.MoveNext
Loop

Note the difference between:
<td>" & rs("firstname") & "</td>
and
<td>'" & rs("firstname") & "'</td>

If any first or last name has a space it will not show what's after the space, EG:
if first name = Mary Anne
without the single quotes it will only dispaly Mary



Wind is your friend
Matt
 
Old May 20th, 2004, 06:54 PM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to drumph Send a message via Yahoo to drumph
Default

Thanks Mat41 and Jonax.. Your comment really did the trick..

D.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Numbering - For each Navy1991_1 XSLT 3 July 2nd, 2008 07:56 AM
Numbering in XSLT Angel1221 XSLT 1 June 10th, 2008 05:07 PM
numbering harag XSLT 2 November 6th, 2003 06:04 AM
numbering problem harag XSLT 1 November 5th, 2003 03:31 PM
XSL numbering be782524 XSLT 2 August 5th, 2003 05:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.