判断数据是否已经出界(rs.eof) 的问题

xieqi 2005-09-21 04:11:57
rs1=conn.execute(\"select top 1 * from table where 1=2\")
这里sql语句显然是没有结果的。

如果我用rs记录集,我马上可以得到一个
rs.eof
但是这里我没有用记录集,我是直接conn.execute的
那么rs1会得到什么。这个rs1可以有一个类似eof的属性嘛?

主要是想问用conn.execute返回的数据,怎么才能知道没有符合条件的记录呢?
...全文
126 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
PcVSBirds 2005-09-22
  • 打赏
  • 举报
回复
set rs=conn.execute("select * from table where 1=2")

if rs.eof or rs.bof then
'输出这里的
response.write "没有记录!"
rs.close
set rs=nothing
response.end
else

do while not rs.eof
response.write rs("")
rs.movenext
loop

end if
itzhiren 2005-09-22
  • 打赏
  • 举报
回复
应该 set rs=conn.execute("select * from table where 1=2")
PcVSBirds 2005-09-22
  • 打赏
  • 举报
回复
set rs=conn.execute("select * from table where 1=2")

if rs.eof or rs.bof then
else

end if
xieqi 2005-09-22
  • 打赏
  • 举报
回复
注意
我这里没有
set rs=server.createobject("adodb.recordset")
也没有
rs.open"select * from table",conn,1,1
哦。
我为了节约开销,因此不用 set 来实例化rs对象。
我是直接 rs=conn.execute("select * from table where 1=2")
rs在这里可能只是一个数组,我也不是很清楚。
xieqi 2005-09-22
  • 打赏
  • 举报
回复
我怎么不行?
代码如下:
<!--#include file="conn.asp"-->
<%
rs=conn.execute("select * from table where 1=2")
'if not rs.eof then
aa=rs(0)
'end if
%>
========================
ADODB.Field error '800a0bcd'

BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录。

/test/ab.asp, line 5

---------------------------
<!--#include file="conn.asp"-->
<%
rs=conn.execute("select * from table where 1=2")
if not rs.eof then
aa=rs(0)
end if
%>
==============================
Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'rs.eof'

/test/ab.asp, line 4


maxsolomon 2005-09-21
  • 打赏
  • 举报
回复
你不用rs.eof,怎么知道到没到底
  • 打赏
  • 举报
回复
如果没有数据的话,就是
if rs.eof then

没有数据
END IF
  • 打赏
  • 举报
回复
rs.open"select * from table",conn,1,1
count=rs.recordcount

if not rs.eof then

..

end if
MOTA 2005-09-21
  • 打赏
  • 举报
回复
可以使用EOF 和BOF
HHH3000 2005-09-21
  • 打赏
  • 举报
回复
conn.execute就是返回一个recordset对象~~

28,406

社区成员

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

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