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

📄 445_2.asp

📁 ASP编程实例入门与提高书中的实例源代码
💻 ASP
字号:
<html>
<head>
<TITLE>RecordSet应用</TITLE>
</head>
<body bgcolor="#FFFFFF">
<!--#INCLUDE file="ADOVBS.INC" -->
<% 
connectme="DSN=pubs;user id=sa;pwd=123"
sqltemp="select * from publishers"

mypage=request.querystring("whichpage") '获得需要显示的页数

If  mypage="" then    '如果为空,则显示第一页
   mypage=1
end if
mypagesize=request.querystring("pagesize")    '获得每页大小

If  mypagesize="" then
   mypagesize=3           '如果每页大小为空,则默认为3条记录
end if

set rstemp=Server.CreateObject("ADODB.Recordset")
rstemp.cursorlocation=aduseclient
rstemp.cachesize=5
rstemp.open sqltemp,connectme
rstemp.movefirst
rstemp.pagesize=mypagesize
maxcount=cint(rstemp.pagecount)
rstemp.absolutepage=mypage
howmanyrecs=0
howmanyfields=rstemp.fields.count -1
response.write "Page " & mypage & " of " & maxcount & "<br>"
%>
<table border=1><tr>
<%
'先输出表头字段
for i=0 to howmanyfields %>
<td><b>
<%=rstemp(i).name %>
</B> </TD>
<% next %>
</tr>
<% 
do while not rstemp.eof and howmanyrecs<rstemp.pagesize
%>
<tr>
<% 
for i = 0 to howmanyfields
%>
<td valign=top><%=rstemp(i)%> </td>
<% next %>
</tr>
<%
rstemp.movenext
howmanyrecs=howmanyrecs+1
loop
rstemp.close
set rstemp=nothing
%>
</table><p>
<%
pad="0"
scriptname=request.servervariables("script_name")
for counter=1 to maxcount
   If counter>=10 then
      pad=""
   end if
   ref="<a href='" & scriptname & "?whichpage=" & counter
   ref=ref & "&pagesize=" & mypagesize & "'>" & pad & counter & "</a>"
   response.write ref & " "
   if counter mod 10 = 0 then
      response.write "<br>"
   end if
next
%>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -