ADODB.Recordset (0x800A0BCD)BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除

来源:百度知道 编辑:UC知道 时间:2024/06/08 02:36:34
错误类型:
ADODB.Recordset (0x800A0BCD)
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。
/servmore.asp, 第 35 行
下面是详细代码
<%const MaxPerPage=20
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j,m,nclassid
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
nclassid=cint(request("nclassid"))
dim sql_zx,rs
set rs=server.CreateObject("adodb.recordset")
sql="select * from service where nclassid="&nclassid&" order by ID desc"
rs.open sql,conn,1,1
totalPut=rs.recordcount

通常这个,你的数据库没有数据的话,即使你用RS.eof或RS.bof的时个都会出现错误,这是正常的,解决方法,,在ASP代码前加:<%on error resume next%>
表示出错跳过。
提示,这句话有时会影响其它的错误调试。因为它是忽略错误继续执行程序的,所以你在做其它东西的时候得去掉或是变成注释<%'on error resume next%>

记录不存在,应该先判断一下.
nclassid=request("nclassid")
If IsNull(nclassid) Or IsEmpty(nclassid) Or IsNumeric(nclassid)=0 Then nclassid=0
nclassid = CInt(nclassid)
If nclassid<1 Then
'参数无效....
'进行错误处理
End If

dim sql_zx,rs
set rs=server.CreateObject("adodb.recordset")
sql="select * from service where nclassid="&nclassid&" order by ID desc"
rs.open sql,conn,1,1
If Rs.Eof And Rs.Eof Then
totalPut = 0
Else
totalPut=rs.recordcount
End If

If totalPut>0 Then
'这里分页....
Else
'No Records Matched.......
End If
好几年没有写VB了,我想应该是这样吧

当前操作的记录不存在了.