?? 7.1 splitpage.asp
字號:
<%
iConc = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=<登錄SQL Server實例的用戶服務名>;Password=<用戶密碼>;Initial Catalog=Northwind;Data Source=<SQL Server服務器名>"
Set iRs =Server.CreateObject("ADODB.Recordset")
iRs.CursorLocation = 3 '使用客戶端游標
iRs.Open "Customers", iConc, 1,1 '打開要分頁顯示的記錄集
iPageSize = 10 階段 '每頁的記錄數(頁大小)
iRs.PageSize = iPageSize
iCurrentPage=CInt(Request("index")) '設置當前顯示第幾頁
If iCurrentPage < 1 Or iCurrentPage > iRs.PageCount Then
iCurrentPage = 1
End If
iRs.AbsolutePage = iCurrentPage
'翻頁處理代碼
iPageMove = "第" + CStr(iCurrentPage) + "頁"
iPageMove = iPageMove + ",每頁" + CStr(iPageSize) + "條記錄"
iPageMove = iPageMove + ",共" + CStr(iRs.PageCount) + "頁"
If iRs.PageCount > 1 Then
If iCurrentPage > 1 Then
iPageMove = iPageMove + " <a Href=""@Pages@?index=1"">首頁</a>"
iPageMove = iPageMove + " <a Href=""@Pages@?index=" + CStr(iCurrentPage-1) + """>上頁</a>"
End If
If iCurrentPage < iRs.PageCount Then
iPageMove = iPageMove + " <a Href=""@Pages@?index=" + CStr(iCurrentPage+1) + """>下頁</a>"
iPageMove = iPageMove + " <a Href=""@Pages@?index=" + CStr(iRs.PageCount) + """>末頁</a>"
End If
End If
iPageMove = Replace(iPageMove,"@Pages@","splitpage.asp") ‘splitpage.asp是分頁處理的asp文件名
iCount = 0 '控制顯示的記錄數
%>
<p align="center">客戶信息一覽表</p>
<table width="100%" border="1">
<tr>
<%For iI=0 to iRs.Fields.Count-1 '顯示字段名%>
<th><%=iRs.Fields(iI).Name%></th>
<% Next %>
</tr>
<%While iRs.Eof=False And iPageSize > 0 '循環顯示當前面的記錄%>
<tr>
<% For iI=0 to iRs.Fields.Count-1 %>
<td><%=iRs.Fields(iI).Value%></td>
<% Next %>
</tr>
<%
iRs.MoveNext
iPageSize = iPageSize - 1
Wend
'關閉記錄集
iRs.Close
Set iRs = Nothing
%>
</table>
<p align="Right"><%=iPageMove %></p>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -