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>
...全文
56 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
李燚 2009-08-08
  • 打赏
  • 举报
回复
谢谢各位了,我的代码可以分页了,O(∩_∩)O哈哈~
play1982 2009-08-08
  • 打赏
  • 举报
回复
李燚 2009-08-08
  • 打赏
  • 举报
回复
错误类型:
ADODB.Recordset (0x800A0BCD)
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。
/countArticle.asp, 第 54 行


浏览器类型:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)

网页:
GET /countArticle.asp

时间:
zhangaijing 2009-08-08
  • 打赏
  • 举报
回复
少了一个判断 当点下一页的 时候超出了pagecount时的处理
lukalea 2009-08-08
  • 打赏
  • 举报
回复
报什么错,你也得写出来啊!
  • 打赏
  • 举报
回复
晕死,这么简单的,你点击下一页的时候没有把folderN这个值传过去,能不出错吗?
应该是
把folderN = Request.Form("folderName")改为folderN = Request("folderName")
然后
在每个连接那加一个传值
比如
<a href="?curpage= <%=curpage-1%>&folderName=<%=folderN%>">上一页 </a>
其他的分页链接同样加上即可

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧