?
Solved

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

Posted on 2003-03-06
9
Medium Priority
?
376 Views
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...

   <thead>
          <tr>
            <td bgcolor="#000080"><font color="#FFFFFF" size="1" face="Arial">
            <b>ID</b></font></td>
            <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>
          </tr>
        </thead>
Thanks!!
0
Comment
Question by:jvescio
8 Comments
 
LVL 4

Accepted Solution

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

CR

<%

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
               
Else
                   
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
         
Rs.MoveNext
         
         
Loop    
     

Response.Write "Done"

%>
0
 
LVL 4

Expert Comment

by:CRagsdell
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..."

CR
0
 

Author Comment

by:jvescio
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?

JV
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
LVL 4

Expert Comment

by:CRagsdell
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.

CR
0
 
LVL 10

Expert Comment

by:substand
ID: 8085777
what language are you using?
0
 

Author Comment

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

I am editin code generated by Frontpage 2002.

Here is an example:

<html>

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

<body>


<table width="100%" border="1">
  <thead>
    <tr>
      <td><b>ID</b></td>
      <td><b>lastname</b></td>
      <td><b>firstname</b></td>
      <td><b>pw</b></td>
      <td><b>username</b></td>
      <td><b>dept</b></td>
    </tr>
  </thead>
  <tbody>
  <!--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>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT * FROM employees"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=6 align=left width=""100%"">No records returned.</td></tr>"
fp_sDataConn="employees"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=5
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_iDisplayCols=6
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->
<!--webbot bot="DatabaseRegionStart" endspan i-checksum="53682" -->
  <tr>
    <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="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>
    <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>
    <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>
    <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>
    <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>
    <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>
  </tr>
  <!--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>
</table>

</body>

</html>
0
 

Expert Comment

by:CleanupPing
ID: 9276087
jvescio:
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 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 12

Expert Comment

by:monosodiumg
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.

monosodiumg
EE Cleanup Volunteer
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
In this article, we will show how to detach and attach a database and then show how to repair a corrupt database and attach it, If it has some errors. We will show how to detach and attach using SSMS or using T-SQL sentences.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…

601 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