ASP分页显示出错。

来源:百度知道 编辑:UC知道 时间:2024/05/27 20:45:23
我的思想是当查询数据库时记录集不为空时按分页显示正确显示数据,当记录集为空时则输出“没有相关内容”。我的代码如下,但实际调试过程中,代码没有达到我预期的效果,当记录集为空时则出错了,报错结果如下,请各位大侠看看,帮我修改下代码。

报错结果:
ADODB.Recordset 错误 '800a0bcd'

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

/b.asp,行 187

网页ASP源码入下:
......
<%
dim sj
sj=request.QueryString("lei")
oshen=request.QueryString("shen")
odaxue=request.QueryString("daxue")

if oshen<>""and odaxue=""then
exec="select * from nr where name like '%"&sj&"%' and shen='"&oshen&"'order by id desc"
end if
if oshen=""then
exec="select * from nr where name like '%"&sj&"%'order by id desc"
end if
if odaxue<>""then
exec="select * from nr where name like '%"&sj&"%' and shen='"&oshen&"' and daxue='&

if rs.eof and rs.bof then
response.write("还没有留言")
else
提到分页前

<%
if rs.eof and rs.bof then

for i=1 to rs.pagesize
if rs.Eof then Exit for
%>

<table width="718" border="1" cellspacing="0" bordercolor="#FFFFFF">
<tr bgcolor="#FCFEED" onmouseover="this.style.backgroundColor='#FFFF66'" onmouseout="this.style.backgroundColor=''">
<td width="387" height="25"><a href="xx.asp?id=<%=rs("id")%>" target="_blank"><%=rs("name")%></a></td>
<td width="177" height="25"><span class="STYLE2"><%=rs("daxue")%></span></td>
<td width="140" height="25"><span class="STYLE2"><%=rs("time")%></span