今天首都机场延误原因:错误类型:ADODB.Recordset (0x800A0E78)对象关闭时,不允许操作。

来源:百度文库 编辑:高考问答 时间:2024/04/30 01:45:26
错误类型:
ADODB.Recordset (0x800A0E78)
对象关闭时,不允许操作。
/ln/manage/manageuser.asp, 第 70 行

出现的问题:
if rs.eof And rs.bof then
Response.Write "<p align='center' class='contents'> 对不起,没有找到此用户!</p>"

部分原代码:
<%'开始分页
Const MaxPerPage=20
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

dim namekey,checkbox,action
action=request.QueryString("action")
checkbox=request("checkbox")
namekey=request("namekey")
if namekey="" then namekey=request.QueryString("namekey")
if checkbox="" then checkbox=request.querystring("checkbox")
'//
set rs=server.CreateObject("adodb.recordset")
if namekey="" then
select case action
case "all"
rs.open "select username,userid,userzhenshiname,logins,adddate from [user] ",conn,1,1
case "huiyuan"
rs.open "select username,userid,userzhenshiname,logins,adddate from [user] where reglx=1",conn,1,1
case "vip"
rs.open "select username,userid,userzhenshiname,logins,adddate from [user] where reglx=2",conn,1,1
end select
else
if checkbox=1 then
rs.open "select username,userid,userzhenshiname,logins,adddate from [user] where username like '%"&namekey&"%' ",conn,1,1
else
rs.open "select username,userid,userzhenshiname,logins,adddate from [user] where username='"&namekey&"' ",conn,1,1
end if
end if

if err.number<>0 then
response.write "数据库中无数据"
end if

if rs.eof And rs.bof then
Response.Write "<p align='center' class='contents'> 对不起,没有找到此用户!</p>"
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,"manageuser.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"manageuser.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"manageuser.asp"
end if
end if
end if

sub showContent
dim i
i=0

%>

这个错误应当是记录集rs并没有打开、记录集cursor已经在末尾等原因所致。以前遇到过同样的问题,记不起具体的解决方式了。

建议如下:
将代码改写为:
rs is nothing => report db error
rs.recordcount=0(针对你的用户,或者直接从DB直接查询,或者从查询后的rs中filter一下)=>report no data found.