Contents of bcb1.asp:
<html> <body bgcolor="#cccccc"> <Table border="1"> <tr><td valign='middle' bgcolor='#999999'><img src="captsm.gif"></td> <td valign='middle' bgcolor='#999999'><center><font color="#ffffff"><font face="Comic Sans MS"> <br> <b>A Simple ASP Example<br>Single Level Control Break</b> <br> </td></tr></table> </center> <p> <font face="Comic Sans MS"><b> <p> <p>Begin execution...<p> <% sub writegrandtotal (wlabel,wcount) response.write "<tr><td bgcolor='#ffffff' align='right'>"+wlabel+" = "+cstr(wcount)+"</td><td></td><td></td><td></td></tr>" end sub sub writetotal (wlabel,wcount) response.write "<tr><td colspan='2' bgcolor='#ccccff' align='right'>"+wlabel+" = "+cstr(wcount)+"</td>" response.write "<td></td<td></td></tr>" end sub sub writenewheader(newloc) response.write "<tr><td></td><td bgcolor='#ccccff' align='center'><b>"+newloc+"</td>" response.write "<td></td><td></td></tr>" end sub ' '***top of main ' set rs=Server.CreateObject("ADODB.Recordset") SQLString="SELECT * FROM badge order by bloc ASC, bid ASC" response.write "<P>Opening badge rs with SQLstring=<br>--->"+cstr(SQLString)+"<------ " response.write "<P><b>NOTE: Primary sort is location, secondary sort is badge id</b>" rs.open SQLString,"DSN=gl001;UID=gl001;PWD=11111;" response.write "<P>Recordset opened OK<p>" 'if NOT rs.EOF then ' '*** recordset is NOT empty -- work to do ' c=0 cloc=0 st1_control_check=0 lastloc=rs("bloc") call writenewheader(rs("bloc")) response.write "<table border='1'>" response.write "<tr><td align='center'><b>Badge Id</td><td align='center' bgcolor='#ccccff'><b>Location</td><td align='center'><b>First Name</td><td align='center'><b>Last Name</td></tr>" while NOT rs.EOF ' ' ' if lastloc <> rs("bloc") then call writetotal ("<b>Location Count for "+cstr(lastloc)+"</b>",cloc) call writenewheader(rs("bloc")) st1_control_check=st1_control_check+cloc cloc=0 end if ' '***** now the detail ' response.write "<tr><td>"+cstr(rs("bid"))+"</td>" response.write "<td align='center'>"+cstr(rs("bloc"))+"</td>" response.write "<td>"+cstr(rs("bfirstname"))+"</td>" response.write "<td>"+cstr(rs("blastname"))+"</td></tr>" cloc=cloc+1 c=c+1 lastloc=rs("bloc") rs.movenext wend call writetotal ("<b>Location Count for "+cstr(lastloc)+"</b>",cloc) st1_control_check=st1_control_check+cloc call writegrandtotal ("<b>TOTAL FOR All LOCATIONS</b>",c) response.write "</table><p>Records read="+cstr(c) if c=st1_control_check then response.write "<p>Control total check OK -- Number of records read ("+cstr(c) response.write ") = Sum of first level subtotals ("+cstr(st1_control_check)+")" else response.write "<p>Control total check FAILS -- Number of records read ("+cstr(c) response.write ") NOT = Sum of first level subtotals ("+cstr(st1_control_check)+")" end if 'else ' response.write "<p>Table is empty -- No records returned" 'end if response.write "<p>Terminating Normally -- "+cstr(now) rs.close set rs=nothing %> <p> <a href="bdoc.asp?fl=1"> Click here for the program listing </a> (bcb1.asp)<br> </body> </html>
***** end of file *** printed: 109 lines on: 11/23/2009 5:50:58 AM