【使用ASP網頁讀取資料庫 --- 分頁瀏灠紀錄】
開啟資料庫連結
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "FileDSN=" & Server.MapPath("database.dsn")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT * FROM 票選種類 Where Status<2", conn, 3
%>
設定瀏灠分頁
<%
' 先以 Request方法讀取 CurPage 的值
rs.PageSize = 20 '
每頁顯示紀錄筆數
TotalPage = rs.PageCount
if CurPage > TotalPage then CurPage = TotalPage
if CurPage < 1 then CurPage = 1
rs.AbsolutePage = CurPage
%>
使用迴圈逐筆顯示資料
<%
L = 0
While Not rs.EOF and L<rs.PageSize
L = L + 1
%>
<%=rs("欄位名稱")%> ' 輸出該筆紀錄中某欄位的資料
<%
rs.MoveNext
Wend
%>