ADODB.Recordset (0x800A0E78)对象关闭时,不允许操作。

fangkunsong 2008-12-04 11:21:06
问题如标题,出错行为标红色行
<!--#include file="../inc/fk_conn.asp"-->
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../images/css2.css" rel="stylesheet" type="text/css">
<script language=javascript>
function allcheck()
{
var a = document.getElementsByTagName("input");
if(a[0].checked==true){
for (var i=0; i<a.length; i++)
if (a[i].type == "checkbox") a[i].checked = false;
}
else
{
for (var i=0; i<a.length; i++)
if (a[i].type == "checkbox") a[i].checked = true;
}
}
</script>
</head>
<body>

<%dim action
action=request.QueryString("action")%>

.... <%'开始分页
Const MaxPerPage=12
dim totalPut
dim CurrentPage
dim TotalPages
dim j
dim sql
if Not isempty(request("page")) then
currentPage=Cint(request("page"))
else
currentPage=1
end if
set rs=server.CreateObject("adodb.recordset")
select case action
case "no"
rs.open "select shop_books.bookname,shop_books.bookid,shop_pinglun.pinglunid,shop_pinglun.pingluncontent,shop_pinglun.pinglunname,shop_pinglun.pinglundate from shop_pinglun,shop_books where shop_books.bookid=shop_pinglun.bookid and shop_pinglun.shenhe=0 order by shop_pinglun.pinglundate desc",conn,1,1
case "yes"
rs.open "select shop_books.bookname,shop_books.bookid,shop_pinglun.pinglunid,shop_pinglun.pingluncontent,shop_pinglun.pinglunname,shop_pinglun.pinglundate from shop_pinglun,shop_books where shop_books.bookid=shop_pinglun.bookid and shop_pinglun.shenhe=1 order by shop_pinglun.pinglundate desc",conn,1,1
end select
if rs.eof And rs.bof then
%>
<table width="100%" border="1" align=center cellspacing="0" cellpadding="3" bordercolordark="#FFFFFF" bordercolorlight="#666666">
<tr>
<td bgcolor="#ece9d8"><div align="center"><font color=red>目前还没有未审阅评论!</font></div></td>
</tr>
</table>
<br>
<%else
totalPut=rs.recordcount

if currentpage<1 then
currentpage=1
end if

if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if

if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"managepinglun.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"managepinglun.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"managepinglun.asp"
end if
end if
end if

sub showContent
dim i
dim i_mun
dim i_color
i=0:i_mun=1

%>

... <%

do while not rs.eof
if i_mun mod 2=1 then
i_color="#ffffff"
else
i_color="#eeeeee"
end if%>

<tr bgcolor=<%=i_color%>>

<td><div align="center"><input name="shenhe" type="checkbox" id="shenhe" value="<%=rs("pinglunid")%>"></div></td>
<td><div align="center"><%if len(rs("bookname"))>15 then
response.write "<a href=../book.asp?id="&rs("bookid")&" target=_blank>"&left(trim(rs("bookname")),12)&"...</a>"
else
response.write "<a href=../book.asp?id="&rs("bookid")&" target=_blank>"&trim(rs("bookname"))&"</a>"
end if
%></div></td>
<td><div align="center"><% if len(rs("pingluncontent"))>20 then
response.write "<a href=# onClick=""javascript:window.open('listpinglun.asp?id="&rs("pinglunid")&"','','width=300,height=120,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');return false;"" title="&trim(rs("pingluncontent"))&">"&left(trim(rs("pingluncontent")),17)&"...</a>"
else
response.write "<a href=# onClick=""javascript:window.open('listpinglun.asp?id="&rs("pinglunid")&"','','width=300,height=120,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');return false;"" title="&trim(rs("pingluncontent"))&">"&trim(rs("pingluncontent"))&"</a>"
end if%></div></td>
<td><div align="center"><%
response.write rs("pinglunname")
%></div></td>
<td><div align="center"><%
response.write month(rs("pinglundate"))&"/"&day(rs("pinglundate"))
%></div></td>
</tr>
<%
i_mun=i_mun+1
i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing
%>
.... <%
End Sub

Function showpage(totalnumber,maxperpage,filename)
Dim n

If totalnumber Mod maxperpage=0 Then
n= totalnumber \ maxperpage
Else
n= totalnumber \ maxperpage+1
End If

Response.Write "<form method=Post action="&filename&"?action="&action&">"
Response.Write "<p align='center' class='contents'> "
If CurrentPage<2 Then
Response.Write "<font class='contents'>首页 上一页</font> "
Else
Response.Write "<a href="&filename&"?page=1&action="&action&" class='contents'>首页</a> "
Response.Write "<a href="&filename&"?page="¤tPage-1&"&action="&action&" class='contents'>上一页</a> "
End If

If n-currentpage<1 Then
Response.Write "<font class='contents'>下一页 尾页</font>"
Else
Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&action="&action&" class='contents'>"
Response.Write "下一页</a> <a href="&filename&"?page="&n&"&action="&action&" class='contents'>尾页</a>"
End If
Response.Write "<font class='contents'> 页次:</font><font class='contents'>"¤tPage&"</font><font class='contents'>/"&n&"页</font> "
Response.Write "<font class='contents'> 共有"&totalnumber&"条记录 "
Response.Write "<font class='contents'>"
Response.Write "</form>"
End Function
%>
</td>
</form>


.....
...全文
233 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
toury 2008-12-04
  • 打赏
  • 举报
回复

<%
set rs=server.CreateObject("adodb.recordset")
select case action
case "no"
sql="select shop_books.bookname,shop_books.bookid,shop_pinglun.pinglunid,shop_pinglun.pingluncontent,shop_pinglun.pinglunname,shop_pinglun.pinglundate from shop_pinglun,shop_books where shop_books.bookid=shop_pinglun.bookid and shop_pinglun.shenhe=0 order by shop_pinglun.pinglundate desc"
case "yes"
sql"select shop_books.bookname,shop_books.bookid,shop_pinglun.pinglunid,shop_pinglun.pingluncontent,shop_pinglun.pinglunname,shop_pinglun.pinglundate from shop_pinglun,shop_books where shop_books.bookid=shop_pinglun.bookid and shop_pinglun.shenhe=1 order by shop_pinglun.pinglundate desc"
end select
response.write sql

if rs.state<>1 then rs.close
rs.open sql,conn,1,1

if rs.eof And rs.bof then '如果还报对象关闭错误,检查你的SQL语句
%>
chinayuy 2008-12-04
  • 打赏
  • 举报
回复
3楼说的没错
select case action
action这个变量,你没有赋值,那
case "yes" or case "no"
就不会被执行,rs对象就不会被打开,所以,当你执行rs.bof and rs.eof的时候,就会提示对象关闭!

你应该在select case action 的前面把action这个变量读出来

问题就出在

action=request.QueryString("action")
上面那句,可能,在你上个页面没有传值过来,或者你测试的时候没有加上
如:page.asp?action="yes"

但这个action必须是"yes"或"no"字符串,不然,还是会出错!
virgo2008 2008-12-04
  • 打赏
  • 举报
回复
为什么这么喜欢用咒怨里面的头像啊 看的我就害怕!
layers2323 2008-12-04
  • 打赏
  • 举报
回复
.
不耐烦 2008-12-04
  • 打赏
  • 举报
回复
眼力好啊~
layers2323 2008-12-04
  • 打赏
  • 举报
回复
select case action
case "no"
case "yes"

这个语句的问题。 看看有没有执行?
  • 打赏
  • 举报
回复
对象关闭,提示很明显
sy_binbin 2008-12-04
  • 打赏
  • 举报
回复
<%
i_mun=i_mun+1
i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing
end if
%>
tomscat 2008-12-04
  • 打赏
  • 举报
回复
select case别把两个都定死,设个default的,否则case非no非yes,那rs永远也不会open了

28,409

社区成员

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

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