欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

分頁顯示之超級(jí)提速版

 更新時(shí)間:2006年12月26日 00:00:00   作者:  
大家知道,asp本身提供分頁功能,但是,如果數(shù)據(jù)量很大的時(shí)候,分頁顯示起來,每換一頁都要等N長時(shí)間,那是人們最討厭的事情。那為什么每換一頁都要這么長時(shí)間呢?其實(shí),事實(shí)上每換一個(gè)頁面,后臺(tái)就從數(shù)據(jù)庫中檢索一次數(shù)據(jù),這樣一來數(shù)據(jù)量大了,自然速度緩慢。這當(dāng)中我們可以看出它做了很多次重復(fù)的工作。數(shù)據(jù)的檢索只要一次就夠了,因?yàn)閿?shù)據(jù)沒被操作過,無論檢索幾次結(jié)果都是一樣的。我們的目標(biāo)就是要把這當(dāng)中的重復(fù)檢索次數(shù)減少到最少,1次或者2次。方法就是:把檢索好的數(shù)據(jù)保存起來(比如你可以在登錄成功后就在后臺(tái)檢索你要的數(shù)據(jù),把檢索出來的存為數(shù)組放入session,然后再跳轉(zhuǎn)到要顯示數(shù)據(jù)的頁面),當(dāng)然這里可以用session變量來保存(好像用cookie無法保存),不過我知道它的極限是多少,如果數(shù)據(jù)量大到使session變量溢出的話,那我也無計(jì)可施了。廢話少說了,下面說明下怎么個(gè)保存數(shù)據(jù)法?
首先要從數(shù)據(jù)庫讀取數(shù)據(jù),建議使用存儲(chǔ)過程讀取
Set cmd = Server.CreateObject("ADODB.Command")
With cmd
.ActiveConnection=conn
.CommandType=&H0004 '存儲(chǔ)過程
.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
哈哈,數(shù)據(jù)已經(jīng)讀出,接下來就該對(duì)數(shù)據(jù)進(jìn)行分頁顯示了。。
page----當(dāng)前頁
frompage----頁面開始記錄位置
topage-----頁面結(jié)束紀(jì)錄位置
pagesize----每頁顯示的記錄條數(shù)
n---記錄總數(shù)
yushu-----最后一頁的記錄數(shù)
resultArray=session("arr")
n=UBound(resultArray,2)+1
pagesize=5
'response.write "<scri"&"pt>alert('"&n&"')"
'response.write "</script>"
yushu=n mod pagesize
if yushu=0 then
totalpage=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

frompage=(page-1)*pagesize
topage=frompage+pagesize-1
If page=totalpage Then
frompage=(page-1)*pagesize
topage=frompage+yushu-1
End if
end If
有什么地方說的不對(duì),請(qǐng)多多指教
演示地址:http://fishbone31.w3.zccn.net 
我這個(gè)網(wǎng)站因?yàn)樯弦豁撓乱豁撍⑿碌亩际钦?,而非讀取數(shù)據(jù)頁[body.asp],所以速度不是很理想。
賬號(hào)密碼均為test

相關(guān)文章

最新評(píng)論