注册 登录
编程论坛 新人交流区

[求助]sql的问题

读书危害健康 发布于 2007-11-04 20:01, 401 次点击

<%
set rs = server.CreateObject ("adodb.recordset")
sql = "select top 5 * from news where pic<>'' and lm<>'13'"

lm里面有记录,但
错误类型:
ADODB.Field (0x800A0BCD)
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。
/index.asp, 第 223 行
如果改成lm里面没有的记录,如:select top 5 * from news where pic<>'' and lm<>'100'反而正常。 这是怎么回事?
问题补充:<%
set rs = server.CreateObject ("adodb.recordset")
if not (rs.eof and rs.bof) then
sql = "select top 5 * from news where pic<>'' and lm<>'13'"
rs.open sql,conn,1,1
pic1=rs("pic")
link1=rs("url")
text1=rs("title")
rs.movenext
pic2=rs("pic")
link2=rs("url")
text2=rs("title")
rs.movenext
pic3=rs("pic")
link3=rs("url")
text3=rs("title")
rs.movenext
pic4=rs("pic")
link4=rs("url")
text4=rs("title")
rs.movenext
pic5=rs("pic")
link5=rs("url")
text5=rs("title")
rs.close
set rs=nothing
conn.close
set conn=nothing
end if
%>
错误类型:
ADODB.Recordset (0x800A0E78)
对象关闭时,不允许操作。
/index.asp, 第 204 行

11 回复
#2
wangdudu2007-11-04 20:09
这个问题也困扰我很久了,真希望那位大虾出来解答一下~
#3
读书危害健康2007-11-04 21:47

继续顶

#4
随缘小强2007-11-05 10:51
if not (rs.eof and rs.bof) then
你位置放错了,你还没建立集合怎么就能判断rs是否到达集合尾部还是在集合开始的位置?

set rs = server.CreateObject ("adodb.recordset")
sql = "select top 5 * from news where pic<>'' and lm<>'13'"
rs.open sql,conn,1,1
if not (rs.eof and rs.bof) then
pic1=rs("pic") '此处的赋值可以使用循环来实现
link1=rs("url")
text1=rs("title")
rs.movenext
pic2=rs("pic")
link2=rs("url")
text2=rs("title")
rs.movenext
pic3=rs("pic")
link3=rs("url")
text3=rs("title")
rs.movenext
pic4=rs("pic")
link4=rs("url")
text4=rs("title")
rs.movenext
pic5=rs("pic")
link5=rs("url")
text5=rs("title")
end if
rs.close '对象rs和conn一般在最后关闭并且释放资源
set rs=nothing
conn.close
set conn=nothing

[此贴子已经被作者于2007-11-5 10:52:07编辑过]

#5
读书危害健康2007-11-06 20:27
以下是引用随缘小强在2007-11-5 10:51:24的发言:
if not (rs.eof and rs.bof) then
你位置放错了,你还没建立集合怎么就能判断rs是否到达集合尾部还是在集合开始的位置?

set rs = server.CreateObject ("adodb.recordset")
sql = "select top 5 * from news where pic<>'' and lm<>'13'"
rs.open sql,conn,1,1
if not (rs.eof and rs.bof) then
pic1=rs("pic") '此处的赋值可以使用循环来实现
link1=rs("url")
text1=rs("title")
rs.movenext
pic2=rs("pic")
link2=rs("url")
text2=rs("title")
rs.movenext
pic3=rs("pic")
link3=rs("url")
text3=rs("title")
rs.movenext
pic4=rs("pic")
link4=rs("url")
text4=rs("title")
rs.movenext
pic5=rs("pic")
link5=rs("url")
text5=rs("title")
end if
rs.close '对象rs和conn一般在最后关闭并且释放资源
set rs=nothing
conn.close
set conn=nothing

还是不行啊
错误类型:
ADODB.Field (0x800A0BCD)
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。
/index.asp, 第 219 行

#6
l5251690702007-11-06 21:21
看不懂 ,不知道是说明语言
#7
t是变量2007-11-06 21:44
因为那是不等号。
#8
donghuige2007-11-07 09:27
sql = "select top 5 * from news where pic<>'' and lm<>'13'"你说不正确,而
sql = "select top 5 * from news where pic<>'' and lm<>'100'"正确,错误可能是
引用:“当前的记录已被删除,所需的操作要求一个当前的记录。”
你的记录数据是movenext读的,top 5 lm<>'13'的有5条吗,看看数据库里的记录
#9
读书危害健康2007-11-07 20:40
以下是引用donghuige在2007-11-7 9:27:20的发言:
sql = "select top 5 * from news where pic<>'' and lm<>'13'"你说不正确,而
sql = "select top 5 * from news where pic<>'' and lm<>'100'"正确,错误可能是
引用:“当前的记录已被删除,所需的操作要求一个当前的记录。”
你的记录数据是movenext读的,top 5 lm<>'13'的有5条吗,看看数据库里的记录

有啊,10多条呢?

#10
读书危害健康2007-11-07 20:52
sql = "select top 5 * from news where pic<>'' and lm<>'13'"
把lm<>'13'改成lm='13'程序正常,如果只是sql = "select top 5 * from news where pic<>'',不需要判断程序也正常。但都不是我要的效果,是这样的,lm是我数据库中news表中的栏目字段,pic是图片字段,我是想在网页中显示除了第13个栏目外,其他所有栏目中有图片信息文章中的图片。
#11
ouquansi2007-11-07 22:17
不知道干什么的
#12
shengzhiq2007-11-07 23:22
1