杨洋给工作人员闻脚:求救:ASP 缺少对象: '' 咋整!各位大虾帮帮忙!

来源:百度文库 编辑:高考问答 时间:2024/05/11 17:40:09
我想在文章的显示页面下方加上网友评论,可是总显示下面的错误

Microsoft VBScript 运行时错误 错误 '800a01a8'

缺少对象: ''

/view.asp,行 253

253行:<%do while not r6.eof%>

代码:

<%

Submit=request.form("Submit")
if Submit<>"" then
nicheng=request.form("nicheng")
neirong=request.form("neirong")

set r6=server.createobject("adodb.recordset")
s6="Select * from pinglun "
r6.open s6,conn,1,3

r6.addnew
r6("nicheng")=nicheng
r6("neirong")=neirong
r6.update

r6.close
set r6=nothing
conn.close
set conn=nothing
end if
%>

<%do while not r6.eof%>
<table width="100%" border="0" cellspacing="0">
<tr bgcolor="#E1F4EE">
<td colspan="3" class="style6">网友[<%=r6("nicheng")%>]认为    参评时间:<%=r6("date")%></td>
</tr>
<tr>
<td width="6%" bgcolor="#FFFFCC"> </td>
<td width="88%" bgcolor="#FFF9DD"><%=r6("neirong")%></td>
<td width="6%" bgcolor="#FFF9DD"> </td>
</tr>
<tr>
<td width="6%"></td>
<td width="88%"></td>
<td width="6%"><h5></h5></td>
</tr>
</table>
<%
r6.movenext
loop
%>

把<%

Submit=request.form("Submit")
if Submit<>"" then
nicheng=request.form("nicheng")
neirong=request.form("neirong")

set r6=server.createobject("adodb.recordset")
s6="Select * from pinglun "
r6.open s6,conn,1,3

r6.addnew
r6("nicheng")=nicheng
r6("neirong")=neirong
r6.update

r6.close
set r6=nothing
conn.close
set conn=nothing
end if
%>
改成
<%

set r6=server.createobject("adodb.recordset")
s6="Select * from pinglun "

Submit=request.form("Submit")
if Submit<>"" then
nicheng=request.form("nicheng")
neirong=request.form("neirong")
r6.open s6,conn,1,3

r6.addnew
r6("nicheng")=nicheng
r6("neirong")=neirong
r6.update

r6.close
end if
r6.open s6,conn,1,1
%>

前面有这么几句:
r6.close
set r6=nothing
conn.close
set conn=nothing
end if
,这些内容把rs6关闭并清空了,所以你再do while not r6.eof的时候r6这个对象就不寻在了。可以把前面那几句去掉,或者重新查询一次。

r6.close
set r6=nothing
conn.close
set conn=nothing

以上代码导致的
r6这个对象已经不存在了

r6.close
set r6=nothing
conn.close
set conn=nothing
end if
你上边这句已经关闭了r6记录集,
后边怎么用<%do while not r6.eof%>?
里边的r6已经close了,并且已经nothing了
把r6.close
set r6=nothing
conn.close
set conn=nothing
放在最后即可解决错误

这是因为缺少conn对象或者rs对象,按我说的两种测试一下,一定可以搞定
一,检查你是不是已经打开了conn对象。比如说include 了conn.asp等文件
或者,你再第一次操作数据时是不是关闭了conn对象
二。是不是你第二次用rs对象进行读取数据时,忘了先打开rs对象