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