| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1009 人关注过本帖
标题:asp中sql查询语句的问题
取消只看楼主 加入收藏
读书危害健康
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2006-9-23
收藏
 问题点数:0 回复次数:3 
asp中sql查询语句的问题
数据库中有news 和lm两张表,news表中有lm和pic字段,lm表中有lmid字段,我现在想查询news表中pic字段中的含有图片信息的内容,但又不需要news表的lm字段中lm=13的所有内容,或者是需要lm表中lmid=1的内容,与是我使用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'反而正常,select top 5 * from news where pic<>'' and lm='13' 也正常,这是怎么回事?以上说的正常都是程序运行正常,并不表示能达到我想要的效果,后来我又用sql = "select top 5 * from news where (pic<>''(select * from lm where lmid='1'))"和 sql = "select top 5 * from news where pic<>'' inner join lm where lmid='1'",都报错,哪位老鸟能告诉我该怎么写,万分感谢!急等。。。。。。


附: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
set rs=nothing
conn.close
set conn=nothing
向这样加上判断语句后,
错误类型:
ADODB.Field (0x800A0BCD)
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。
搜索更多相关主题的帖子: 查询 asp 语句 sql 
2007-11-08 23:54
读书危害健康
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2006-9-23
收藏
得分:0 
以下是引用hmhz在2007-11-9 0:08:36的发言:
楼上的错不在那地方
应该是这句
sql = "select top 5 * from news where pic<>'' and lm<>'13'"
改成
sql = "select top 5 * from news where pic<>"" and lm<>13"

改后还是有错
错误类型:
Microsoft JET Database Engine (0x80040E14)
字符串的语法错误 在查询表达式 'pic<>" and lm<>13' 中。
/index.asp, 第 205 行


[url=http://shop34791159.]淘宝小店![/url]
2007-11-09 19:24
读书危害健康
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2006-9-23
收藏
得分:0 
以下是引用madpbpl在2007-11-8 23:57:52的发言:
从这句开始调整一下if not (rs.eof and rs.bof) then
if rs.eof and rs.bof then
response.write "没有找到数据"
else
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
set rs=nothing
conn.close
set conn=nothing
改后还是有错
错误类型:
ADODB.Field (0x800A0BCD)
BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。

[url=http://shop34791159.]淘宝小店![/url]
2007-11-09 19:27
读书危害健康
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2006-9-23
收藏
得分:0 
问题已经解决,虽然没什么帮助,但还是谢谢你们的回答,

[url=http://shop34791159.]淘宝小店![/url]
2007-11-09 23:37
快速回复:asp中sql查询语句的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011381 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved