Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    187
    Thanks
    5
    Thanked 0 Times in 0 Posts

    next and previous.

    i want to create a search resualts page that will draw the data from a query in an access database. there will be many resualts so i will need to implement previous and next buttons. i cant find any tutorials. is there a db command tht could b usefull? what would be the most efficiant way to do this, so tht the database connection is kept as short as possible? cheers.

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    there are many examples of database recordset paging on the web. If you do a search of this forum you will find a number of results also




    Here is a link where I provided some code to help someone to page their recordset

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    187
    Thanks
    5
    Thanked 0 Times in 0 Posts
    it may help me find something, knowing the proper name ;-)

    as the the database part, is it more efficiant to access just say 20 resualts at a time, or can i access the whole lot, and store them somewhere so i dont have to keep accsing the db when the user clicks next?

  • #4
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    you could do that. Just use the GetRows() method to put your data into an Array. Then in your for loop use a variable that is contained in the click of the arrow to jump to the next 20 records .

    Your asp code might look something like this
    Code:
    sSQL = "SELECT * FROM MyDB"
    oRs.Open sSQL, myDSN
    If Not oRs.EOF Then
        myArray = oRs.GetRows()
        HasRecords = True
    Else
        HasRecords = False
    End If 
    
    If HasRecords = True Then
    	If Len(Request("lowerlimit")) = 0 Then
    	    BeginPoint = 0
    	Else
    	    BeginPoint =  Request("lowerlimit")
    	End If
    
    	If Len(Request("upperlimit")) = 0 Then
    		If Ubound(myArray,2) < 19 Then
    			EndPoint = Ubound(myArray,2)
    		Else
    			EndPoint = 19
    		End If
    	Else
    	    EndPoint =  Request("upperlimit")
    	End If
    
    	For iRows = BeginPoint to EndPoint
    		Response.Write "<tr><td>" & myArray(0,iRows) & </td>"
    		Response.Write "<td>" & myArray(1,iRows) & </td>"
    		Response.Write "<td>" & myArray(2,iRows) & </td>"
    		Response.Write "<td>" & myArray(3,iRows) & </td></tr>"
    	Next
    Else
    	Response.Write "No Records"
    End If
    Last edited by miranda; 07-02-2007 at 07:30 PM.

  • #5
    Regular Coder
    Join Date
    Mar 2006
    Posts
    187
    Thanks
    5
    Thanked 0 Times in 0 Posts
    that cool, i dont think there is, but is there any way to keep that array over several pages?

  • #6
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    I haven't tried putting an array into a session variable but it may be possible. I don't know why you would want to do it though. You are much better off making a call to the db to fill the array on a page by page basis. there is much less overhead involved. On an example with recordset paging, it is actually only 1 page of code with the page posting back to itself. you could even do it with ajax displaying the data


  •  

    Posting Permissions

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