recordset分页,我点击下一页就出错了
李燚 2009-08-08 09:23:27 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>湘西州交警支队</title>
<link href="../../leecss/content.css" rel="stylesheet" type="text/css" />
</head>
<body>
{LB_头部通用}
<div id="main">
<%
dim conn,mdbfile
mdbfile=server.mappath("KS_Data/KesionCMS5.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "driver={microsoft access driver (*.mdb)};uid=sa;pwd=989066;dbq="&mdbfile
%>
<table width="80%" cellpadding="0" cellspacing="0" border="0">
<tr>
<th align="center">
文章标题
</th>
<th align="center">
浏览次数
</th>
<th align="center">
发布时间
</th>
<th align="center">
发布单位
</th>
</tr>
<%
folderN = Request.Form("folderName")
sql="select ID,Tid,Title,Adddate,Hits from KS_Article where Tid = (select ID from KS_Class where FolderName='"&folderN&"')"
set rs = server.CreateObject("adodb.recordset")
rs.open sql,conn,3 '要加这句才能打开记录集
rs.pagesize=12
'curpage=Request.QueryString("curpage")
'if curpage="" then
' curpage=1
'End if
'rs.absolutepage=curpage
if request.querystring("curpage") <> empty then
curpage=request.querystring("curpage")
else
curpage=1
end if
rs.absolutepage=curpage '定位到URL后面参数page指定的页码
for i= 1 to rs.pagesize
if rs.eof then
exit for
end if
'do while not rs.eof
%>
<tr>
<th align="left" width="40%">
<%=rs("Title")%>
</th>
<th align="center">
<%=rs("Hits")%>
</th>
<th align="center">
<%=rs("Adddate")%>
</th>
<th align="center">
<%=folderN%>
</th>
</tr>
<%
rs.movenext
next
'rs.Movenext
' loop '退出循环
%>
<tr><th align="center" colspan="4">
当前第 <%=curpage%> 页 每页 <%=rs.pagesize%> 篇 页 共 <%=rs.pagecount%> 页
<%if curpage=1 then%>首页
<%else%>
<a href="?curpage=1">首页</a>
<%end if%>
<%if curpage=1 then%>
上一页
<%else%>
<a href="?curpage=<%=curpage-1%>">上一页</a>
<%end if%>
<%if rs.pagecount<curpage+1 then%>
下一页
<%else%>
<a href="?curpage=<%=curpage+1%>">下一页</a>
<%end if%>
<%if rs.pagecount<curpage+1 then%>
尾页
<%else%>
<a href="?curpage=<%=rs.pagecount%>">尾页</a>
<%
End if
rs.close
set rs=nothing '关闭数据
%>
</th></tr>
</table>
</div>
<p> </p>
<div id="footer">
{LB_底部通用}
</div>
</body>
</html>