asp出现错误 '80020009'

来源:百度知道 编辑:UC知道 时间:2024/09/20 11:42:05
错误 '80020009'
../inc/sub.asp,行 70
Function get_channelup(cid)
Set rsa = maxz.exec("select zt_upid from zt_type where zt_typeid = "&cid, 1)
If rsa(0) > 0 Then 这是第70行
Set rsc = maxz.exec("select zt_typeid, zt_typename, zt_en from zt_type where zt_typeid = "&rsa(0), 1)
If Not rsc.eof Then
Dim resurt(3)
For gi=0 To 2
resurt(gi) = rsc(gi)
Next
rsc.close
Set rsc = Nothing
Else
resurt = ""
End If
Else
resurt = ""
End If
rsa.close
Set rsa = Nothing
get_channelup = resurt
End Function
还是不明白能不能给个容易懂的答案

Function get_channelup(cid)
Set rsa = maxz.exec("select zt_upid from zt_type where zt_typeid = "&cid, 1)
if not rsa.eof then
If rsa(0) > 0 Then 这是第70行
Set rsc = maxz.exec("select zt_typeid, zt_typename, zt_en from zt_type where zt_typeid = "&rsa(0), 1)
If Not rsc.eof Then
Dim resurt(3)
For gi=0 To 2
resurt(gi) = rsc(gi)
Next
rsc.close
Set rsc = Nothing
Else
resurt = ""
End If
Else
resurt = ""
End If
end if
rsa.close
Set rsa = Nothing
get_channelup = resurt
End Function

先判断一下记录集是否为空
,因为这种错误的原因就是数据表里没东西.

这有什么不明白的?
你的那个第七十行 rs(0)>0,有问题.如果数据库里没东西的话.rs(0)这个表达式就不能用.
你这样写,if rs.eof then 判断一下数据库里是否有内容.

很多情况都会遇到,记录集空,查询一个表的而另一个表没有值等,简单办法on error resume next,基本就OK了

Set rsa = maxz.exec("select zt_upid from zt_type where zt_typeid = "&ci