分页显示的问题,为什么点击下一页或尾页,找不到页面?在线等
<html>
<head>
<%
Set conn = Server.CreateObject("ADODB.Connection")
strcon="provider=microsoft.jet.oledb.4.0;data source="& _
server.mappath("zhuboyi.mdb")
conn.Open strcon
Set rs = Server.CreateObject ("ADODB.Recordset")
sql="select Detail,Title,Date from new order by Date desc"
rs.Open sql, conn, 1
page=1 ' 设置变量PAGE=1
rs.PageSize = 3 '每页显示记录数
if Not IsEmpty(Request("Page")) then '如果PAGE已经初始化...
Page = CInt(Request("Page")) '接收PAGE并化为数字型赋给PAGE变量
if Page > rs.PageCount then '如果接收的页数大于总页数
rs.AbsolutePage = rs.PageCount '设置当前显示页等于最后页
elseif Page <= 0 then '如果page小于等于0
Page = 1 '设置PAGE等于第一页
else
rs.AbsolutePage = Page '如果大于零,显示当前页等于接收的页数
end if
End if
Page = rs.AbsolutePage
%>
<%
For i = 1 to rs.PageSize
if rs.EOF then
Exit For
end if '利用for next 循环依次读出记录
%>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<table width=95% border=1 align=center>
<tr>
<td width="2%" height="17"><img src="images/dot.gif" width="6" height="6" border="0"></td>
<td width="3%" height="17"><img src="images/arrow.gif" width="5" height="5"></td>
<td width="443" height="17"><% =rs("Detail") %><br><% =rs("Title") %></td>
<td width="74" height="17"><% =rs("Date") %></td>
</tr> </table>
<%
rs.MoveNext
Next
%>
<%
if page<>1 then%>
<a Href="dangtai5.asp?Page=<% = 1%>">首页</a>
<a Href="dangtai5.asp?ToPage=<% =Page -1 %>">上一页</a>
<%end if %>
<%
if page<>rs.pagecount then %>
<a Href="dangtai5.asp?ToPage=<% =Page + 1%>">下一页</a>
<a Href="dangtai5.asp?ToPage=<% = rs.PageCount%>">尾页</a>
<%
end if %>
</body>
<%
rs.close
Set rs = Nothing
conn.close
set conn=nothing
%>
</body>
</html>