Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Paging problem.Help really needed
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Paging problem.Help really needed

 Post Reply Post Reply
Author
brolinuk View Drop Down
Newbie
Newbie
Avatar

Joined: 24 October 2003
Location: United Kingdom
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote brolinuk Quote  Post ReplyReply Direct Link To This Post Topic: Paging problem.Help really needed
    Posted: 18 November 2003 at 12:07pm

I have tried to use paging function to list the search results. but an error encounter while I press the next button to move to next page of the search result.

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/cohl/search.asp, line 211

Here is my code search.asp, It is a bit long, but I have no other way to explain it more clear.

  strType = Request.Form("select")//
  strKey = Request.Form("key")//

%> 
   <!--#include file="dbcon.asp"-->

 <!--#include file="ADOVBS.inc"-->
<%
  'Set how many records per page we want
  Const NumPerPage = 5
 
  'Retrieve what page we're currently on
  Dim CurPage
  If Request.QueryString("CurPage") = "" then
   CurPage = 1 'We're on the first page
  Else
   CurPage = Request.QueryString("CurPage")
  End If
   
  set rs=server.CreateObject("ADODB.RecordSet") 
  if  strType="PC Software" then
   strNo=3   
   elseif strType="PDA Software"then
   strNo=2
   elseif strType="E-Books" then
   strNo=1
  End if
  
  rs.CursorLocation = adUseClient
  rs.CacheSize = NumPerPage

  if strType<>"Entire Site"  then    
   if strKey<>"" then
    strSQL = "SELECT down.* FROM down WHERE type='"&strNo & "' AND name LIKE '%"&strKey&"%'"
   Else
    strSQL = "SELECT down.* FROM down WHERE type=type='"&strNo  & "'"
   End if  
  Else
   if strKey<>"" then
    strSQL = "SELECT down.* FROM down WHERE name LIKE '%"&strKey&"%'"   
   Else
    strSQL = "SELECT down.* FROM down"   
   End if 
  End if  
 'rs.open "SELECT down.* FROM down WHERE type='"&strNo & "' AND name LIKE '%"&strKey&"%'", adoCon 
 rs.open strSQL, adoCon 
 i=0

    rs.MoveFirst
    rs.PageSize = NumPerPage
    Dim TotalPages
    TotalPages = rs.PageCount
    rs.AbsolutePage = CurPage
    Dim count
    count=0

 do while not rs.EOF And Count < rs.PageSize 
%>
               <table >........... </table>'Html stuffs.............               
<% 
   Count = Count + 1
   rs.MoveNext
   Loop
  
   'Print out the current page # / total pages
   Response.Write("Page " & CurPage & " of " & TotalPages & "<P>")
  
   'Display Next / Prev buttons
   if CurPage > 1 then
    'We are not at the beginning, show the prev button
    Response.Write("<INPUT TYPE=BUTTON VALUE=PREV ONCLICK=""document.location.href='search.asp?curpage=" & curpage - 1 & "';"">")
   End If
  
   if CInt(CurPage) <> CInt(TotalPages) then
    'We are not at the end, show a next button
    Response.Write("<INPUT TYPE=BUTTON VALUE=NEXT ONCLICK=""document.location.href='search.asp?curpage=" & curpage + 1 & "';"">")
   End If

As you can find, during the first round of the do while loop, it stopped while the number of record is equal to the desired number of records per page. Once the next button is pressed, the search.asp page is recalled with a new vaule for the curpage. As the rs pointer is not at EOF, it should continue to do the while loop with the new curpage value. Therefore, I don't know where is this error messege from. I suppose it is becuase the original search.asp page require the value from the other page (strKey and strType) but not passed to the  next search result page(search.asp?curpage=2). I am not so sure about this and no idea to solve it. Any body please help me out this problem. Thanks



Edited by brolinuk
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.