我的.asp文件中出现错误,我不知道如何解决这个问题(我不知道ASP)。我得到的错误如下



ADODB.字段错误"800a0bcd">

BOF 或 EOF 为 True,或者当前记录已被删除。请求的操作需要当前记录。

/索引.asp,第 216 行

和216行——

<%ip=0
set rsEx=conn.execute("select * from products where featured=1")
while not rsEx.eof
ip=ip+1
set rsMasSku=conn.execute("select top 1* from productSkus where masterid="&rsEx("id")&" order by price")
dprice=rsMasSku("dprice")  
price=rsMasSku("price")
if cDbl(dprice) > 0 then
finalPrice=cDbl(price)-cDbl(price)*cDbl(dprice)/100
else
finalPrice=price
end if
%>

错误的根源很可能是以下代码块:

set rsMasSku=conn.execute("select top 1* from productSkus where masterid="&rsEx("id")&" order by price")
dprice=rsMasSku("dprice")  
price=rsMasSku("price")

现在发生的情况是,如果第二个 rsMasSku 记录集返回给定 rsEx("id"( 值的数据,则对 rsMasSku("dprice"( 或 rsMasSku("price"( 的引用根本不存在,并且返回错误。

因此,解决方案是在实例化 rsMasSku 记录集添加一个 EOF 检查(类似于while not rsEx.eof

set rsMasSku=conn.execute("select top 1* from productSkus where masterid="&rsEx("id")&" order by price")
if not rsMasSku.EOF then    
' ... now you can access the rsMasSku fields et cetera ...
else
' ... do nothing ... or maybe think of something else to do ...
end if

相关内容

最新更新