不可思议的问题!

hareqiqi 2001-04-21 04:07:00
请帮帮忙,提示错误:
display_id=0 错误 '80020009'
发生意外。

/add_text.asp, 行35
部分原码:


set cn = Server.CreateObject("ADODB.Connection")
cnpath = "DBQ=" & server.mappath("database.mdb")&";pwd="
cn.Open "DRIVER={Microsoft Access Driver (*.mdb)};" & cnpath

set rs0 = Server.Createobject("ADODB.RecordSet")
sql0 = "SELECT obj,obj_id,display_id FROM display WHERE lesson_id="&lesson_id&" AND chap_id="&chap_id&" AND jie_id="&jie_id&" ORDER BY display_id DESC"
rs0.open sql0,cn,3,3

response.write "display_id="&display_id

while ((not rs0.eof) AND (rs0("display_id")<>display_id)) '此处35行
rs0.movenext
wend

while not rs0.eof AND rs0("obj")<>"text"
rs0.movenext
wend

response.write rs0("display_id")

if rs0.eof then
text_id = 0
else
text_id = rs0("obj_id")
end if

response.write text_id

rs0.close
...全文
97 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hareqiqi 2001-04-21
  • 打赏
  • 举报
回复
ok!搞定,问题已经解决!
原码如下:
set cn = Server.CreateObject("ADODB.Connection")
cnpath = "DBQ=" & server.mappath("database.mdb")&";pwd="
cn.Open "DRIVER={Microsoft Access Driver (*.mdb)};" & cnpath

set rs0 = Server.Createobject("ADODB.RecordSet")
sql0 = "SELECT obj,obj_id,display_id FROM display WHERE lesson_id="&lesson_id&" AND chap_id="&chap_id&" AND jie_id="&jie_id&" ORDER BY display_id DESC"
rs0.open sql0,cn,3,3

response.write "display_id="&display_id

flag = 1
if rs0.eof then
flag = 0
elseif rs0("display_id")=display_id then
flag = 0
end if

while flag
rs0.movenext
if rs0.eof then
flag = 0
elseif rs0("display_id")=display_id then
flag = 0
end if
wend

response.write "display_id="&display_id

flag = 1
if rs0.eof then
flag = 0
elseif rs0("obj")="text" then
flag = 0
end if

while flag
rs0.movenext
if rs0.eof then
flag = 0
elseif rs0("obj")="text" then
flag = 0
end if
wend

if rs0.eof then
text_id = 0
else
text_id = rs0("obj_id")
end if

response.write text_id

rs0.close
hareqiqi 2001-04-21
  • 打赏
  • 举报
回复
我也想到这个问题了
所以正在改进
vb真弱!
呵呵
BrentIvan 2001-04-21
  • 打赏
  • 举报
回复
一样的概念,Vb语法和C不一样
If 表达式1 Or 表达式2 Then
或者
If 表达式1 And 表达式2 Then

在C或Java中,如果第一个表达式不成立,编译器是不会去判断第二个表达式的。而在Vb中是会的。
所以
if (rs0.eof) OR (rs0("display_id")=display_id) then
如果rs0.eof成立,编译器还是会判断rs0("display_id")=display_id,这样是会出错的。

懂了吗,所以应该放在两句里
hareqiqi 2001-04-21
  • 打赏
  • 举报
回复
改你那样是可以
但是这两种表达并不等价
我改成这样:
flag = 1
if (rs0.eof) OR (rs0("display_id")=display_id) then '37行
flag = 0
end if

while flag
rs0.movenext
if ((not rs0.eof) AND (rs0("display_id")<>display_id)) then
flag = 0
end if
wend

可还是不对:
display_id=0 错误 '80020009'
发生意外。

/add_text.asp, 行37
hareqiqi 2001-04-21
  • 打赏
  • 举报
回复
我试试
先谢谢你!
BrentIvan 2001-04-21
  • 打赏
  • 举报
回复
试一下:

while (not rs0.eof)
If (rs0("display_id") <> display_id) Then
rs0.movenext
End If
wend
hareqiqi 2001-04-21
  • 打赏
  • 举报
回复
关注!

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧