Repeat <thead> every 10 rows...SQL 2000 / ASP

Posted on 2003-03-06
Medium Priority
Last Modified: 2012-05-04
I would like to repeat the column heading every 10 rows on the results page of a SQL 2000 query. Does anyone have experience with this?

Here is my HEADER ROW...

            <td bgcolor="#000080"><font color="#FFFFFF" size="1" face="Arial">
            <td bgcolor="#000080"><b>
            <font face="Arial" size="1" color="#FFFFFF">EDIT</font></b></td>
            <td bgcolor="#000080"><font color="#FFFFFF" size="1" face="Arial">
            <b>Last Name</b></font></td>
            <td bgcolor="#000080"><font color="#FFFFFF" size="1" face="Arial">
            <b>First Name</b></font></td>
Question by:jvescio
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

CRagsdell earned 1000 total points
ID: 8083445
Here is an example that should do what you want...



Set Cm = Server.CreateObject("ADODB.Command")

Cm.ActiveConnection = Application("Whatever")
Cm.CommandText = "SELECT * FROM tablename"
Cm.CommandType = 1

Set Rs = Cm.Execute

Response.Write "<thead><tr><td>If left out the rest of your header to keep from typing too much...</td></tr></thead>"          

strCounter = 0

Do While Not Rs.EOF          
If strCounter <> 10 Then
Response.Write "<tr><td>Details go here...</td></tr></thead>"          

strCounter = strCounter + 1
Response.Write "<thead><tr><td>If left out the rest of your header to keep from typing too much...</td></tr></thead>"          

strCounter = 0
End If

Response.Write "Done"


Expert Comment

ID: 8083457
Ooops, take out the </thead> tag in the details line...

and there is a typo in "If left out the rest..."

It should read "I left out the rest..."


Author Comment

ID: 8083904
Thanks for responding,

Are you saying this code replaces my current query completely?  If so, where would code reside?  Above the head tag? In the body?

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI


Expert Comment

ID: 8083978
Use your current query, as this was just an example of how the looping and counting of 10 lines between each <thead></thead> would work.

Just noticed, you might have to replace the "If strCounter <> 10 Then" line with "If strCounter <> 9 Then" since I am resetting to 0 after each 10 records.

Run the query anywhere on your page prior to where you want to show the results. Where you are now showing the results, use my sample (revised as necessary to meet your needs) to build the parts of the table where you want the header to repeat.

LVL 10

Expert Comment

ID: 8085777
what language are you using?

Author Comment

ID: 8087649
I am using ASP and SQL Server 2000.

I am editin code generated by Frontpage 2002.

Here is an example:


<% ' FP_ASP -- ASP Automatically generated by a Frontpage Component. Do not Edit.
FP_CharSet = "windows-1252"
FP_CodePage = 1252 %>


<table width="100%" border="1">
  <!--webbot bot="DatabaseRegionStart" s-columnnames="ID,lastname,firstname,pw,username,dept,manager,costcenter,bizunit,address1,address2,city,state,zip,homephone,cube_num,fax,email,location,did,present_num,cell_num,state_exemptions,fed_exemptions,bday,SecurityLevel,status,fullname,street_address,remote_fax_num" s-columntypes="3,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202" s-dataconnection="employees" b-tableformat="TRUE" b-menuformat="FALSE" s-menuchoice s-menuvalue b-tableborder="TRUE" b-tableexpand="TRUE" b-tableheader="TRUE" b-listlabels="TRUE" b-listseparator="TRUE" i-listformat="0" b-makeform="TRUE" s-recordsource="employees" s-displaycolumns="ID,lastname,firstname,pw,username,dept" s-criteria s-order s-sql="SELECT * FROM employees" b-procedure="FALSE" clientside suggestedext="asp" s-defaultfields s-norecordsfound="No records returned." i-maxrecords="256" i-groupsize="5" botid="0" u-dblib="_fpclass/fpdblib.inc" u-dbrgn1="_fpclass/fpdbrgn1.inc" u-dbrgn2="_fpclass/fpdbrgn2.inc" tag="TBODY" preview="&lt;tr&gt;&lt;td colspan=64 bgcolor=&quot;#FFFF00&quot; align=&quot;left&quot; width=&quot;100%&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This is the start of a Database Results region. The page must be fetched from a web server with a web browser to display correctly; the current web is stored on your local disk or network.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;" startspan --><!--#include file="_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database Results component on this page is unable to display database content. The page must have a filename ending in '.asp', and the web must be hosted on a server that supports Active Server Pages.</div>");
<% end if %>
fp_sQry="SELECT * FROM employees"
fp_sNoRecords="<tr><td colspan=6 align=left width=""100%"">No records returned.</td></tr>"
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<!--webbot bot="DatabaseRegionStart" endspan i-checksum="53682" -->
    <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,lastname,firstname,pw,username,dept,manager,costcenter,bizunit,address1,address2,city,state,zip,homephone,cube_num,fax,email,location,did,present_num,cell_num,state_exemptions,fed_exemptions,bday,SecurityLevel,status,fullname,street_address,remote_fax_num" s-column="ID" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;ID&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"ID")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="62813" --></td>
    <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,lastname,firstname,pw,username,dept,manager,costcenter,bizunit,address1,address2,city,state,zip,homephone,cube_num,fax,email,location,did,present_num,cell_num,state_exemptions,fed_exemptions,bday,SecurityLevel,status,fullname,street_address,remote_fax_num" s-column="lastname" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;lastname&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"lastname")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="16593" --></td>
    <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,lastname,firstname,pw,username,dept,manager,costcenter,bizunit,address1,address2,city,state,zip,homephone,cube_num,fax,email,location,did,present_num,cell_num,state_exemptions,fed_exemptions,bday,SecurityLevel,status,fullname,street_address,remote_fax_num" s-column="firstname" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;firstname&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"firstname")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="21016" --></td>
    <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,lastname,firstname,pw,username,dept,manager,costcenter,bizunit,address1,address2,city,state,zip,homephone,cube_num,fax,email,location,did,present_num,cell_num,state_exemptions,fed_exemptions,bday,SecurityLevel,status,fullname,street_address,remote_fax_num" s-column="pw" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;pw&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"pw")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="6301" --></td>
    <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,lastname,firstname,pw,username,dept,manager,costcenter,bizunit,address1,address2,city,state,zip,homephone,cube_num,fax,email,location,did,present_num,cell_num,state_exemptions,fed_exemptions,bday,SecurityLevel,status,fullname,street_address,remote_fax_num" s-column="username" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;username&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"username")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="19455" --></td>
    <!--webbot bot="DatabaseResultColumn" s-columnnames="ID,lastname,firstname,pw,username,dept,manager,costcenter,bizunit,address1,address2,city,state,zip,homephone,cube_num,fax,email,location,did,present_num,cell_num,state_exemptions,fed_exemptions,bday,SecurityLevel,status,fullname,street_address,remote_fax_num" s-column="dept" b-tableformat="TRUE" b-hashtml="FALSE" b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;dept&lt;font size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;" startspan --><%=FP_FieldVal(fp_rs,"dept")%><!--webbot bot="DatabaseResultColumn" endspan i-checksum="5853" --></td>
  <!--webbot bot="DatabaseRegionEnd" b-tableformat="TRUE" b-menuformat="FALSE" u-dbrgn2="_fpclass/fpdbrgn2.inc" i-groupsize="5" clientside tag="TBODY" preview="&lt;tr&gt;&lt;td colspan=64 bgcolor=&quot;#FFFF00&quot; align=&quot;left&quot; width=&quot;100%&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This is the end of a Database Results region.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;TR&gt;&lt;TD ALIGN=LEFT VALIGN=MIDDLE COLSPAN=64&gt;&lt;NOBR&gt;&lt;INPUT TYPE=Button VALUE=&quot;  |&lt;  &quot;&gt;&lt;INPUT TYPE=Button VALUE=&quot;   &lt;  &quot;&gt;&lt;INPUT TYPE=Button VALUE=&quot;  &gt;   &quot;&gt;&lt;INPUT TYPE=Button VALUE=&quot;  &gt;|  &quot;&gt;  [1/5]&lt;/NOBR&gt;&lt;BR&gt;&lt;/td&gt;&lt;/tr&gt;" startspan --><!--#include file="_fpclass/fpdbrgn2.inc"-->
<!--webbot bot="DatabaseRegionEnd" endspan i-checksum="62730" --></tbody>



Expert Comment

ID: 9276087
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
LVL 12

Expert Comment

ID: 10994337
No comment has been added to this question in more than 245 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
   Accept: CRagsdell http:#8083445

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

EE Cleanup Volunteer

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question