Super Speed version of page display-Experience exchange

Source: Internet
Author: User
As you know, the ASP itself provides paging functionality, but, if the amount of data is very large, when the paging display, each page will have to wait for n long time, that is the most annoying thing people. So why does it take so long to change pages every time? Actually, in fact, every time you change a page, the background retrieves the data from the database, so that the data volume is large and the natural speed is slow. In this we can see that it has done a lot of repetitive work. Data retrieval is sufficient once, because the data has not been manipulated, no matter how many times the search results are the same. Our goal is to reduce the number of repeat searches to a minimum of 1 or 2 times. The method is: to save the retrieved data (such as you can after the successful login in the background to retrieve the data you want, the retrieved storage array into the session, and then jump to the page to display the data), of course, here can be stored with the session variable (as if the cookie cannot be saved) , but I know what the limit is, and if the amount of data is large enough to overflow the session variable, then I can't do anything about it. Say less nonsense, the following instructions how to save the data method?
To read the data from the database first, we recommend using the stored procedure to read
Set cmd = Server.CreateObject ("Adodb.command")
With cmd
. Activeconnection=conn
. commandtype=&h0004 ' Stored procedures
. commandtext= "Guestbookpro"
End with
Dim Resultrs, Resultarray
Set resultrs = cmd. Execute (, Null)
If not resultrs.eof Then
Resultarray = Resultrs.getrows ()
End If
Set Resultrs = Nothing
Set cmd = Nothing
Session ("Arr") =resultarray
Haha, the data has been read out, then the data will be paginated display.
Page----Current pages
FromPage----page Start record location
ToPage-----Page End Record location
PageSize----The number of records displayed per page
N Total number of---records
Yushu number of records-----last page
Resultarray=session ("arr")
N=ubound (resultarray,2) +1
Pagesize=5
' Response.Write ' alert (' &n& ') "
' Response.Write" "
Yushu=n mod pagesize
If yushu=0 then
Total Page=fix (n/pagesize)
Else
Totalpage=fix (n/pagesize) +1
End if
If Request ("page") = "then
Page =1
Else
Page=int (Request ("page"))
End if
if Page>totalpage then
page=1
End if
if page<=0 then
page=totalpage
End If
frompage= (page-1) *pagesize
Topage=frompage+pagesize-1
If Yushu=0 then

frompage= (page-1) *pagesize
topage=frompage+pagesize-1
Else

Frompag E= (page-1) *pagesize
topage=frompage+pagesize-1
If page=totalpage then
frompage= (page-1) *pagesize
T Opage=frompage+yushu-1
End If
End If
There is something wrong, please comment
Demo address: http://fishbone31.w3.zccn.net
I this net Station because the last page of the next page refreshes the whole page, rather than reading the data page [body.asp], so the speed is not very ideal.
Account password is test
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.