网上最常见的分页出现错误了!

haonanernet 2005-05-31 05:31:32
代码如下:
<!--#include FILE="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charecet=gb2312">
<title>无标题文档</title>
<link href="css/showzuopin.css" rel="stylesheet" type="text/css">
</head>

<body >
<%
'conn.Open
set rec=server.createobject("ADODB.recordset")
strecql="select * from up_Images "
rec.open strecql,conn,1,1
PgSz=5
If rec.RecordCount=0 then
response.write "<P><center>对不起,数据库中没有相关信息!</center></P>"
else
rec.PageSize = Cint(PgSz) '设定PageSize属性的值
Total=INT(rec.recordcount / PgSz * -1)*-1 '计算可显示页面的总数
PageNo=Request("pageno")
if PageNo="" Then
PageNo = 1
else
PageNo=PageNo+1
PageNo=PageNo-1
end if
ScrollAction = Request("ScrollAction")
if ScrollAction = " 上一页 " Then
PageNo=PageNo-1
end if
if ScrollAction = " 下一页 " Then
PageNo=PageNo+1
end if
if PageNo < 1 Then
PageNo = 1
end if
n=1
rec.AbsolutePage = PageNo
Response.Write "< CENTER>"
position=rec.PageSize*PageNo
pagebegin=position-rec.PageSize+1
if position < rec.RecordCount then
pagend=position
else
pagend= rec.RecordCount
end if
Response.Write "< P>< font color='Navy'>< B>数据库查询结果:< /B>"
Response.Write "(共有"&rec.RecordCount &"条符合条件的信息,显示"&pagebegin&"-"&pagend&")< /font>< /p>"
Do while not (rec is nothing)
RowCount = rec.PageSize
Do While Not rec.EOF and rowcount > 0
If n=1 then
Response.Write "< TR BGCOLOR=#FFFFFF>"
ELSE
Response.Write "< TR BGCOLOR=#EEEEEE>"
End If
n=1-n%>
<td rowspan=3 class=a3 align="center"> <p class="unnamed1"> </p>
<table width="62%" height="155" border="1" bordercolor="#CCCCCC">
<tr>
<td width="43%" height="22"><img src="images/arrow.gif" width="4" height="13"><span style="font-size:9pt">[<%=rec("i_Title")%>]</span></td>
<td width="18%"><span style="font-size:9pt">[<%=rec("uptime")%>]</span></td>
<td width="16%"> </td>
<td width="23%"> </td>
</tr>
<tr>
<td colspan="4"><img src="<%= rec("i_Url")%>" onload='javascript:if(this.width>200)this.width=200'></td>
</tr>
</table></td>
<p class="unnamed1">
<%
RowCount = RowCount - 1
rec.MoveNext
Loop
set rec = rec.NextRecordSet
Loop
Conn.Close
set rec=nothing
set conn=nothing
%>
<FORM METHOD="GET" ACTION="list.asp">
<INPUT TYPE="HIDDEN" NAME="pageno" VALUE="< % =PageNo %>">
<%
if PageNo > 1 Then
response.write "<INPUT TYPE=SUBMIT NAME='ScrollAction' VALUE=' 上一页 '>"
end if
if RowCount = 0 and PageNo <>Total then
response.write "<INPUT TYPE=SUBMIT NAME='ScrollAction' VALUE=' 下一页 '>"
end if
response.write "</FORM>"
End if
%>
</body >
</html>


技术信息(用于支持人员)

错误类型:
ADODB.Recordset (0x800A0CB3)
当前提供程序不支持从单一执行返回多个记录集。
/bbs/TMPaj6t4hcks9.asp, 第 76 行


浏览器类型:
...全文
103 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
baiyunfei 2005-06-01
  • 打赏
  • 举报
回复
不要胡乱使用 NextRecordSet
只有你的查询返回了多于一个记录集的时候才是正确的,这种情况一般只有存储过程才可以返回多个记录集。将 Do while not (rec is nothing)这重循环去掉吧。
判断为空可以这样:
tt=request("textfield1")
if tt="" or not isnumeric(tt) then
tt=0
else
tt=cint(tt)
end if
haonanernet 2005-06-01
  • 打赏
  • 举报
回复
cint(request("textfield1"))
如果textfield1为空,就不能转换
我想当textfield1为空时,转换成0,怎么办?
lonaerd 2005-06-01
  • 打赏
  • 举报
回复
什么年代了还在用这个分页,维护和扩展性好差的。
haonanernet 2005-06-01
  • 打赏
  • 举报
回复
76行是 set rec = rec.NextRecordSet
mymyal123 2005-05-31
  • 打赏
  • 举报
回复
76行是哪行

28,391

社区成员

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

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