Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset Paging

Status
Not open for further replies.

harrysdad

Programmer
May 30, 2002
53
GB
I am attempting to do recordset paging on something I am working on. I have borrowed a script from somewhere that works ok as a stand alone, however I want to pass parameters to it from a form. It all seems to work fine when displaying the first page, however when I try to click for the next page, I get an empty recordset error. I am assuming that this is because the Request.Form parameters that were sent from the first page are no longer "active". Being fairly new to asp I am not sure how to get around this.

Any suggestions gratefully received.
 
pass the new parameters back in hidden inputs from the form.

Chris.

Indifference will be the downfall of mankind, but who cares?
 
The easiest solution would be to toss either the form values or the sql statement into a cookie or session variable (though Querystring is an option also, but this is visible to the end user). I would suggest doing this first thing before querying the database. Something like:
Code:
<%
Option Explicit

'check if there are form values, if so this is first page so set them to session var and set page number
Dim page_no, sql_qry
If Request.Form("mySearchInput") <> "" Then
   Session("mySearchString") = Request.Form("mySearchInput")
   pageNo = 1
ElseIf Len(Session("mySearchString")) = 0 Then
   'zero length value in session var, this mean we hav nothing to search on, should generate an error
   Response.Write "You have not given me anything to search on, how can you expect me to search when you don't type in anything for me to search for? I mean, geez, I'm just a simple ASP script, you can't expect me to read your mind, can you? Why don't you hit the back button, type something in to search for, and we can just pretend this never happened."
   Response.End
ElseIf Request.QueryString("page_no") <> "" Then
   'session has a search value and querystring has a page number
   page_no = request.QueryString("page_no")
Else
   'session has a search string but no page_no was set, default to 1
      page_no = 1
End If

That might be easier to read if you paste it into a code editor.

Basically this assumed you would be puttig the requested page number in the querystring for eveything but the first page (though you could do it for the first page also and it would just be ignored).

You may want to try searching from the keyword search tab above, I think I answered this same exact question in the past few werks and provided severl more examples for cookies or using the querystring to pass the values.

-T
'continue on to

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top