Paging - PLEASE HELP!

Results 1 to 2 of 2

Thread: Paging - PLEASE HELP!

  1. #1
    John C Guest

    Default Paging - PLEASE HELP!

    I have tried several scripts that accomplish paging quite well. The problem is that all of the ones I have seen simply read the entire database. As I have it set up now, you enter search criteria into a form and it is then processed. The first page of results always works fine but when I try to go to the second page of results, my search criteria has disappeared and the results are simply the next set of records in the database. I read something about passing the sql?? I am new to ASP and now very frustrated. Any help would be appreciated.

  2. #2
    Marcel Vogel Guest

    Default RE: Paging - PLEASE HELP!

    Hi,<BR><BR>I had this problem to, but I&#039ve worked it out very well.<BR>You can see it run at http://www.hostfinder.net<BR><BR>Here the code:<BR><BR>&#060;%<BR><BR>Dim strConn, strSQL, intCount, strCheckBox, strPrice, strTraffic, strDiskSpace, objConn, objRec<BR><BR>If Request.QueryString("Move") = "Next" Then<BR>Session("CurrentPage") = Session("CurrentPage") + 1<BR>End If<BR><BR>If Request.QueryString("Move") = "Pref" Then<BR>Session("CurrentPage") = Session("CurrentPage") - 1<BR>End If<BR><BR>If Request.QueryString("Move") = "" Then<BR>Call MakeSQL<BR>Session("CurrentPage") = 1<BR>End If<BR><BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR>Set objRec=Server.CreateObject("ADODB.Recordset")<BR>s trConn = "DSN=hostfinder"<BR>objConn.Open strConn<BR>objRec.Open Session("SQLString"), objConn, 3, 1<BR><BR>If objRec.RecordCount &#060; 1 Then<BR>Response.Write "&#060;font face=&#039Arial, Helvetica&#039 size=&#039 2&#039>&#060;B>HostFinder found no host matching your query.&#060;/B>&#060;/font>"<BR>Else<BR>objRec.PageSize = 5<BR>objRec.AbsolutePage = Session("CurrentPage")<BR>strRecordCount = objRec.RecordCount<BR>If strRecordCount = 1 Then<BR>Response.Write "&#060;font face=&#039Arial, Helvetica&#039 size=&#039 2&#039>HostFinder found " & objRec.RecordCount & " host for you.&#060;/font><BR><BR>"<BR>Else<BR>Response.Write "&#060;font face=&#039Arial, Helvetica&#039 size=&#039 2&#039>HostFinder found " & objRec.RecordCount & " hosts for you.&#060;/font><BR><BR>"<BR>End If<BR><BR>While Not objRec.EOF And NumRows &#060; objRec.PageSize<BR>&#037;&#062;<BR><BR>Here the code to display your database.<BR><BR>&#060;%<BR>NumRows = NumRows + 1<BR>objRec.MoveNext<BR>Wend<BR><BR>If Session("CurrentPage") > 1 Then<BR>&#037;&#062;<BR>&#060;a href="search.asp?Move=Pref">Prev&#060;/A><BR>&#060;%<BR>End If<BR><BR>If Session("CurrentPage") &#060; objRec.PageCount Then<BR>&#037;&#062;<BR>&#060;a href="search.asp?Move=Next">Next&#060;/A><BR>&#060;%<BR>End If<BR>End If<BR>objRec.close<BR>objConn.close<BR>&#037;&#062 ;<BR><BR>&#060;!-- #include file="include/menu_bottom.inc" --><BR><BR>&#060;%<BR>Sub MakeSQL<BR><BR>Session("CurrentPage") = ""<BR>Session("SQLString") = ""<BR><BR>strHostingPlan = Request.Form("HostingPlan")<BR>strServer = Request.Form("Server")<BR>strPrice = Request.Form("Price")<BR>strTraffic = Request.Form("Traffic")<BR>strDiskSpace = Request.Form("DiskSpace")<BR><BR>For intCount = 1 to Request.Form("Options").Count<BR>strCheckBox = strCheckBox & " AND " & Request.Form("Options")(intCount) & " = true "<BR>Next<BR><BR>If intCount > 1 Then<BR>strCheckBox = Left(strCheckBox, Len(strCheckBox) - 1)<BR>strSQL = "SELECT * FROM Options WHERE 0 = 0" & strCheckBox<BR>Else<BR>strSQL = "SELECT * FROM Options WHERE 0 = 0"<BR>End If<BR><BR>intCount = 0<BR><BR>If strHostingPlan &#060;> "" Then<BR>strSQL = strSQL & " AND " & strHostingPlan & ""<BR>End If<BR><BR>If strServer &#060;> "" Then<BR>strSQL = strSQL & " AND " & strServer & ""<BR>End If<BR><BR>If strPrice &#060;> "" Then<BR>strSQL = strSQL & " AND " & strPrice & ""<BR>End If<BR><BR>If strTraffic &#060;> "" Then<BR>strSQL = strSQL & " AND " & strTraffic & ""<BR>End If<BR><BR>If strDiskSpace &#060;> "" Then<BR>strSQL = strSQL & " AND " & strDiskSpace & ""<BR>End If<BR><BR>strSQL = strSQL & " ORDER BY Price"<BR><BR>Session("SQLString") = strSQL<BR><BR>End Sub<BR>&#037;&#062;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •