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 October 8th, 2003, 03:14 AM
Authorized User
 
Join Date: Sep 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zaeem Send a message via Yahoo to zaeem
Default Problem in Recordset Paging

Hello everybody, I am new to asp, I need help in paging the results of the search. What I want is that, when anyone can seaerch a member only 10 records should be displayed per page. How can I do That.
Any help will be appreciated.
Bye

Zaeem Sherazi
__________________
Zaeem Sherazi
 
Old October 13th, 2003, 03:19 PM
Authorized User
 
Join Date: Jun 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to vinyl-junkie
Default

Here is some sample code which should get you started. Hope it helps. :)

http://www.asp101.com/samples/db_paging.asp

Pat Wong
http://www.napathon.net/ - Music Around The World
For collecting tips, trade and want lists, album reviews and more.
 
Old October 15th, 2003, 12:28 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

<SCRIPT LANGUAGE=javascript>
<!--
function onpagenav()
{
document.form1.page.value=onpagenav.arguments[0];
document.form1.action="pagename.asp"
}
//-->
</SCRIPT>

<%
'''''''connction open''''''''''
set cnn=Server.CreateObject("ADODB.connection")
cnn.Open Application("Cnn_connectionstring")
set rs=Server.CreateObject("ADODB.recordset")
sql="select * from tablename"
rs.open sql,cnn,1,3
'''''pagnav cod''''''
mypage=request("page")
  mypagesize=10
  if mypage= "" then mypage=1
  if not rs.eof then
         rs.movefirst
         rs.pagesize=mypagesize
         maxpages=cint(rs.pagecount)
         maxrecs=cint(rs.pagesize)
         rs.absolutepage=mypage
  else
        maxpages=0
        maxrecs=0
  end if
''''''''''''call the records'''''''''''''''
count=0
do while not(rs.EOF) and count<maxrecs
%>
<tr>
<td width="100%" bgcolor="#ADD7E4"><%=rs("fieldname")%></td>
</tr>
<%
rs.MoveNext()
count=count+1
loop
%>
'''''''''''''use the page number(which place you want to use that place you can paste this code)
<%
      pad=""
      'scriptname=request.servervariables("script_name")
      Response.Write("<tr>")
      Response.Write ("<td colspan='2'>")
      response.write "<table rows='1' cols='1' width='97%'><tr>"
      response.write "<td>"
      response.write ""
      if (mypage mod 10) = 0 then
       counterstart = mypage - 9
      else
       counterstart = mypage - (mypage mod 10) + 1
      end if
      counterend = counterstart + 9
      if counterend > maxpages then counterend = maxpages
      if counterstart <> 1 then
       ref="<a href='javascript:document.form1.submit()' onclick='onpagenav(" & 1 & ")'>"
       ref=ref & "First</a>&nbsp;:&nbsp;"
       Response.Write ref
       ref="<a href='javascript:document.form1.submit()' onclick='onpagenav(" & (counterstart-1) & ")'>"
       ref=ref & "Previous</a>&nbsp;"
       Response.Write ref
      end if
      Response.Write "["
      for counter=counterstart to counterend
       If counter>=10 then
       pad=""
       end if
       if cstr(counter) <> cstr(mypage) then
       'msg=Server.HTMLEncode(msg)
       ref="<a href='javascript:document.form1.submit()' onclick='onpagenav(" & counter & ")'>"
       ref=ref & pad & counter & "</a>"
       else
       ref="<b>" & pad & counter & "</b>"
       end if
       response.write ref
       if counter <> counterend then response.write " "
      next
      Response.Write "]"
      if counterend <> maxpages then
       ref="<a class='linka'><a href='javascript:document.form1.submit()' onclick='onpagenav(" & (counterend + 1) & " )'>"
       ref=ref & "Next </a>"
       Response.Write ref
       ref="<a href='javascript:document.form1.submit()' onclick='onpagenav(" & maxpages & ")'>"
       ref=ref & "Last</a>"
       Response.Write ref
      end if
      response.write "<br>"
      response.write "</td>"
      response.write "</table>"
      Response.Write "</td>"
      Response.Write "<tr>"

%>


surendran





Similar Threads
Thread Thread Starter Forum Replies Last Post
DB recordset paging using ajax paging? kumiko Classic ASP Basics 0 May 26th, 2008 10:23 AM
ASP | db recordset paging PLEASE HELP!! burns Classic ASP Basics 0 February 26th, 2006 09:43 AM
Recordset Paging incorrectly. Please help! phudong3da Dreamweaver (all versions) 4 October 4th, 2005 05:39 PM
Problem with recordset paging Stefania Classic ASP Databases 0 February 11th, 2005 08:59 AM
Getting error w/Paging through recordset Calibus Classic ASP Databases 3 September 2nd, 2004 06:41 PM





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