search with recordset paging 
Author Message
 search with recordset paging

i need to search a recordset for a certain record and then display it.
 when i display it i also need to be able to page to the records
before and after it in the recordset.  right now i can search for a
record or i can page records starting at the beginning but i can't do
the paging from starting in the middle of the recordset. i've looked
at all the tutorials online and done hundreds of searchs for this, but
cant figure out a way to do it.

here is the paging code i have working, but it does not allow me to
jump to the middle:

'connect to database
%> <!-- #include file="includes/connection.inc" --> <%

'get the correct sql command from the search or use a standard if no
search was used
If Request.Form("swlin") <> "" Then
  swlin=Request.Form("swlin")
  MyQuery="Select * from Swlin where swlin='"&swlin&"' "
Else
myagency=session("agency")
  MyQuery="Select * from swlin order by swlin"
End If

'for connection to swlin
set myrs=server.createobject("adodb.recordset")

'open the rs
myrs.open myquery, conn, adOpenStatic, adLockReadOnly

'retrieve the name of the current asp document
sPageURL=Request.ServerVariables("SCRIPT_NAME")

'retrieve the current page number from the querystring
iCurrentPage=Request.QueryString("Page")
If iCurrentPage= "" Or iCurrentPage=0 Then
  iCurrentPage=1
End If

'set the number of records to be displayed on each page
iPageSize=1

'set the recordset pagesize property
myrs.Pagesize=ipagesize

'move to the selected page in the rs
myrs.absolutepage=icurrentpage

'if the current page number is less than the toatal number of pages
then display a link to the next page of results
If CInt(iCurrentPage) < myrs.PageCount Then
   Response.Write "<a href =""" & sPageURL &"?Page= "& (iCurrentPage +
1) & """ > Next Page </a>      "
End If

'if the current page number is greater than the first page then
display a link to the prev page of results
If CInt(iCurrentPage) > 1 Then
   Response.Write "<a href =""" & sPageURL &"?Page= "& (iCurrentPage -
1) & """ > Previous Page </a>"
End If

'display the form

Thanks so much for any help!  this is the last thing i need to do
until i send it off to the customer!

                          -cathy



Sun, 27 Nov 2005 21:40:28 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Search page by page

2. Need help passing SQL Statement to Next and Previous pages for Recordset Paging

3. Display the recordset page by page

4. modules and searching recordsets (for a query)

5. Help file search references Front Page Help files?????

6. VBA and Adobe--Search and Note page number

7. Delete a Page if Value is found in a Search

8. Searching within Text Boxes by Page

9. Search and replaceAll in selected page

10. Search for a word and take action on that page

11. How to Determine Page Number During Search

12. How to search all pages for same word

 

 
Powered by phpBB® Forum Software