Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  ADO: Paging Records
     [next Lesson]   ADO: Count Records in Query

ADO Techniques -- The .maxrecords property

This page demonstrates the capabilities how to display a table from a SQL statement but limit the output to a specific number of records.

   filename=/learn/test/dbmaxrecs.asp

<Test Script Below>


<html><head>
<TITLE>dbmaxrecs.asp</TITLE>
</head><body bgcolor="#FFFFFF">
<!--#INCLUDE VIRTUAL="/ADOVBS.INC" -->
<% 
set rstemp=Server.CreateObject("adodb.Recordset")
rstemp.maxrecords=15
connectme="DSN=Student;uid=student;pwd=magic"
rstemp.open "select * from titles", _
     connectme,adopenstatic
' table display
howmanyfields=rstemp.fields.count -1
%>
<table border=1><tr>
<%
for i=0 to howmanyfields %>
    <td><b><%=rstemp(i).name %></B></TD>
<% next %>
</tr>
<%
do while not rstemp.eof %>
<tr>
<% for i = 0 to howmanyfields%>
    <td valign=top><% = rstemp.fields(i).value %>&nbsp;</td>
<% next %>
</tr>
<%
rstemp.movenext
loop
rstemp.close
set rstemp=nothing
%>
</table></body></html>

There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.