⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 7.1 splitpage.asp

📁 很好的sql 文档,可能邦你成为sql 高手
💻 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 + -