Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 23rd, 2008, 04:03 AM
Registered User
 
Join Date: May 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default 5 record Per Page

Hi

Can anyone tell me how i can edit my Code so that it will only display 5 record per page and then add a link at the bottem to list the next 5 records ?

here is what i have got

Code:
<% 
    pStr = "private, no-cache, must-revalidate" 
    Response.ExpiresAbsolute = #2000-01-01# 
    Response.AddHeader "pragma", "no-cache" 
    Response.AddHeader "cache-control", pStr 
%>

<head>
    <style>
    td { font-size : 8pt; font-family : Verdana, Arial; text-decoration : none; }
    body { font-size : 8pt; font-family : Verdana, Arial; text-decoration : none; }
    </style>
</head>

<body>
<p align="center"><b>All Records Entered :</b></p>
<p align="center"><a href="Burtonshowall.asp">Briggs Of Burton</a> <a href="Bincshowall.asp">Briggs Inc</a><br> <a href="Autoshowall.asp">Briggs Auto</a></p>
<table width=611 height="283" border=0 align="center" cellpadding=3 cellspacing=3 cols=2>
<%
   ' Declaring variables
   Dim rs, data_source, no
   no = 0
   data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\10.0.0.80\phone\employee.mdb"

   ' Creating Recordset Object and opening the database
   Set rs = Server.CreateObject("ADODB.Recordset")
   rs.Open "employees", data_source
   ' Looping through the records to show all of them
   While Not rs.EOF %>
<form action="del.asp" method="post">
<tr>
    <td width="296" height=10 align="right" valign="top">First Name :</td>
    <td align="left" height=10 valign="top" width=294><%=rs("firstname") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top">Sur Name </td>
    <td align="left" height=10 valign="top"><%=rs("surname") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top">Department :</td>
    <td align="left" height=10 valign="top"><%=rs("Department") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top">Site :</td>
    <td align="left" height=10 valign="top"><%=rs("Site") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top">Ext :</td>
    <td align="left" height=10 valign="top"><%=rs("EXT") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top">DDI :</td>
    <td align="left" height=10 valign="top"><%=rs("DDI") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top">Mobile :</td>
    <td align="left" height=10 valign="top"><%=rs("Mobile") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top">Email :</td>
    <td align="left" height=10 valign="top"><%=rs("Email") %></td>
</tr>
<tr>
    <td align="right" height=10 valign="top"><input type="hidden" name="id" value="<%=rs("id")%>"></td>
    <td align="left" height=10 valign="top"><input type="submit" value="Delete" style="height: 25px; width: 100px"></td>
</tr>
<td align="right" height=10 valign="top"><input type="hidden" name="first_name" value="<%=rs("firstname")%>"></td>
<td align="right" height=10 valign="top"><input type="hidden" name="sur_name" value="<%=rs("surname")%>"></td>
</form>
<tr>
  <td>&nbsp;</td>
<td>&nbsp;</td></tr>

  <%
   no = no + 1
   rs.MoveNext
   Wend
   ' Done. Now close the Recordset
   rs.Close
   Set rs = Nothing
 %>
 <tr>
    <td align="right" height=10 valign="top"><b>Total Records Found</b> :</td>
    <td align="left" height=10 valign="top"><%= no %></td>
</tr>
</table>
</body>
</html>
James

 
Old May 24th, 2008, 10:51 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

ASP does not have a built in funtionality that automatically provides paging (which is what you are trying to do) so you will need to roll your own solution:

http://www.asp101.com/Samples/db_paging_aspx.asp

That link should get you started.

hth.
-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
 
Old June 2nd, 2008, 01:21 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

That link is for *ASP.NET* paging!

The correct link is this:
http://www.asp101.com/Samples/db_paging.asp

That code isn't bad. Could be done a tad more efficiently, but it's got all the bells and whistles.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Access Page - New Record JeffGirard Access 5 December 7th, 2007 10:03 AM
WHy does it show 1 record per page instead of 10? gilgalbiblewheel Classic ASP Databases 2 April 27th, 2005 11:03 AM
Calculate page of record lachdanan Classic ASP Databases 1 April 22nd, 2005 08:25 AM
Record locking - user needs the next queued record cbtoolkit SQL Server 2000 0 December 6th, 2004 08:29 AM
dropdown list not selecting record on page load whyulil ASP.NET 1.0 and 1.1 Basics 1 September 8th, 2004 08:29 AM





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