程序代碼部分(fēn):
SELECT TOP 頁大(dà)小 *
FROM TestTable
WHERE (ID > (SELECT MAX(id) FROM (SELECT TOP 頁大(dà)小*頁數 id FROM 表 ORDER BY id) AS T))
ORDER BY ID
ASP超高(gāo)效分(fēn)頁算(suàn)法<%'每頁的(de)記錄數dim pagesizepagesize= "30" '讀出總記錄數,總頁數Dim TotalRecords,TotalPagesSQLstr="Select count(id) As RecordSum From table1"Set Rs=conn.Execute(SQLstr,0,1) TotalRecords=Rs("RecordSum") if Int(TotalRecords/pagesize)=TotalRecords/pagesize thenTotalPages=TotalRecords/pagesizeelseTotalPages=Int(TotalRecords/pagesize)+1end ifRs.Close Set Rs=Nothing '當前頁碼dim pagepage=Request("page")if isnumeric(page)=false thenresponse.write "<SCRIPT language=JavaScript>alert('參數錯誤!');"response.write "window.close();</SCRIPT>"response.endend ifIf page="" or page<1 Then page=1If page-TotalPages>0 Then page=TotalPagespage=int(page)if page=1 thensql="select top "&pagesize&" id,title,time from table1 order by time desc"elsesql="select top "&pagesize&" id,title,time from table1 where time<(SELECT Min(time) FROM (SELECT TOP "&pagesize*(page-1)&" time FROM table1 ORDER BY time desc) AS T) order by time desc"end ifSet rs = Server.CreateObject ("ADODB.Recordset")rs.Open sql,conn,1,1Do While Not rs.Eofresponse.write "每條記錄信息:"&rs("id")&"<br>"rs.movenextlooprs.closeset rs=nothing''翻頁代碼省略……%>