翻页的问题?

litdong 2002-04-03 10:04:12
报错现象:当点击连接时,出现:对象关闭时,操作不被允许。
以下是代码:

'分页处理
dim intCurPage 'as integer
dim intTotalPages 'as integer
dim intRec 'as integer
dim i 'as integer
dim j 'as integer
set rs4=server.CreateObject("adodb.recordset")
rs4.PageSize=5
rs4.CursorLocation=1
rs4.Open strsql,cn,3,1

if request("page")="" then
intCurPage=1
else
if intCurPage<1 then
intCurpage=1
else
if intCurpage>rs4.PageCount then
intCurpagers4.PageCount
else
intCurpage=rs4.PageCount
end if
end if
end if
'<debug>
Response.Write intCurpage
Response.Write rs4.PageCount
'</debug>

rs4.AbsolutePage=intCurpage

if rs4.PageCount=intCurpage then
intrec= rs4.RecordCount-intCurpage*rs4.PageSize
j=0
for i=1 to intrec
j=j+1
if j/2=j\2 then%>
<td bgcolor="#F3F3F3" height=30><%
else%>
<td height=30><%
end if%>   
<img SRC="<%=rs4.Fields("bbsimage")%>"><font class=p12-2>
<a href="news.asp?operid=<%=rs4.Fields("idcontent")%>" target="_blank"><%=rs4.Fields("caption")%>
(<%=day(rs4.Fields("sendtime"))%>日<%=timevalue(rs4.Fields("sendtime"))%>)</a></font>
</td>
<tr>
<%
if not rs4.EOF then
rs4.MoveNext
end if
next
else
for i=1 to rs4.PageSize 'loop
j=j+1
if j/2=j\2 then
%>
<td bgcolor="#F3F3F3" height=30>
<%else%>
<td height=30>
<%end if%>   
<img SRC="<%=rs4.Fields("bbsimage")%>"><font class=p12-2>
<a href="news.asp?operid=<%=rs4.Fields("idcontent")%>" target="_blank"><%=rs4.Fields("caption")%>
(<%=day(rs4.Fields("sendtime"))%>日<%=timevalue(rs4.Fields("sendtime"))%>)</a></font>
</td>
<tr><%
if not rs4.EOF then
rs4.MoveNext
end if
next
end if
%>
</table>
</center>
<% Response.Write " <a href=subsystm1.asp?page=1>首页<a>"%>
<%if intcurpage=1 then%>
<% Response.Write " <span>前一页</span>"%>
<%else%>
<% Response.Write " <a href=subsystm1.asp?page=" & intCurpage-1 & ">前一页<a>" %>
<%end if %>
<%if intcurpage=rs4.PageCount then%>
<% Response.Write " <span>下一页</span>"%>
<%else%>
<% Response.Write " <a href=subsystm1.asp?page=" & intCurpage+1 & ">下一页<a>" %>
<%end if %>
<% Response.Write " <a href=subsystm1.asp?page=" & rs4.PageCount & ">末页<a>"%>

<%rs4.close%>
<%set rs4=nothing%>
...全文
33 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
8988 2002-04-03
  • 打赏
  • 举报
回复
set rs4=server.CreateObject("adodb.recordset")之前应该连接数据库。而你的代码中没有。

28,406

社区成员

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

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