高手赐教--有关分页问题,为什么这样写不对?

Danielchenyu 2004-12-22 11:38:04
<%
dim rs,rs1,sql1
set rs = server.createobject("adodb.recordset")
sql = "SELECT * FROM news where class_num='"&class_num&"' ORDER BY webdate DESC"
'response.write sql
rs.open sql, conn, 1, 1
if rs.eof and rs.bof then
response.write "<br><font size=2>没有相关资讯内容</font>"
jjpage=1
else
dim curpage, i
if request("page")="" then
curpage = 1
else
curpage = cint(request("page"))
end if
rs.pagesize = 15
rs.absolutepage = curpage
for i = 1 to rs.pagesize
%>
<tr>
<td width="5%"> </td>
<td width="4%"><img src="images/news_page.gif" width="10" height="10"></div></td>
<td width="91%" height="30"><a href="news_view.asp?id=<%=rs("id")%>"><%=rs("title")%></a> <font color="#999999">(<%=rs("webdate")%>)</font><SPAN id=Label1>
<%if rs("webdate")>date()-7 then%>
<img src="images/news_new.gif" width="28" height="11">
<%end if%>
</SPAN></td>
</tr><% rs.movenext
if rs.eof then
i = i + 1
exit for
end if
next
end if%>
</table> </td>
</tr>
<tr>
<td height="20" colspan="3"> </td>
</tr>
<tr>
<td colspan="3"><div align="right">
<%if jjpage<>1 then
response.write "本页" + cstr(i-1) + "条/总" + cstr(rs.recordcount) + "条 "
if curpage = 1 then
response.write "首页 前页 "
else
response.write "<a href='news_more.asp?class_num="&strclass&"&page=1'>首页</a> <a href='news_more.asp?class_num="&strclass&"&page=" + cstr(curpage-1) + "'>前页</a> "
end if
if curpage = rs.pagecount then
response.write "后页 末页"
else
response.write "<a href='news_more.asp?class_num="&strclass&"&page=" + cstr(curpage+1) + "'>后页</a> <a href='news_more.asp?class_num="&strclass&"&page=" + cstr(rs.pagecount) + "'>末页</a>"
end if
End If
rs.close
%>
...全文
108 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
vincent_918 2004-12-22
  • 打赏
  • 举报
回复
学习中。。。
honghe1 2004-12-22
  • 打赏
  • 举报
回复
class_num=request("class_num")
madpolice 2004-12-22
  • 打赏
  • 举报
回复
eof检测语句在for循环中的的位置不对,应当在for语句之后立即检测。
madpolice 2004-12-22
  • 打赏
  • 举报
回复
eof检测的位置不对,应当在for语句之后立即检测。
chang1216 2004-12-22
  • 打赏
  • 举报
回复
你的值 没有传过去 class_num
Danielchenyu 2004-12-22
  • 打赏
  • 举报
回复
第一页正常,到第二页就出错,请高手赐教!
Danielchenyu 2004-12-22
  • 打赏
  • 举报
回复
运行后显示的错误:

Microsoft VBScript 编译器错误 错误 '800a03f6'

缺少 'End'

/iisHelp/common/500-100.asp,行242

ADODB.Field 错误 '80020009'

BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。

/aorta-show/news_more.asp,行0
eme520 2004-12-22
  • 打赏
  • 举报
回复
cint(request("page")) 这个是在做什么呀? 还有个CSTR ,有人能告诉我吗?
vincent_918 2004-12-22
  • 打赏
  • 举报
回复
经研究后,建议这么改
<%
dim rs,rs1,sql
strclass=request("class_num") //把值传给strclass
set rs = server.createobject("adodb.recordset")
sql = "SELECT * FROM news where class_num='"&strclass&"' ORDER BY webdate DESC"
'response.write sql
rs.open sql, conn, 1, 1
if rs.eof and rs.bof then
response.write "<br><font size=2>没有相关资讯内容</font>"
jjpage=1
else
dim curpage, i
if request("page")="" then
curpage = 1
else
curpage = cint(request("page"))
end if
rs.pagesize = 20
rs.absolutepage = curpage
for i = 1 to rs.pagesize
%>
mzhmark 2004-12-22
  • 打赏
  • 举报
回复
eof检测不对,应在显示记录前检测,而不是在检测后

28,409

社区成员

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

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