if not(rs.bof and rs.eof) then

来源:百度知道 编辑:UC知道 时间:2024/09/21 23:27:04
我想问一下if not(rs.bof and rs.eof) then这句中的not(rs.bof and rs.eof)是什么意思。他有什么作用,如果没有他会出现什么现像。

<%
if session("admin")="" then
response.redirect "2.htm"
else
if session("flag")>2 then
response.write "<br><p align=center>您没有操作的权限</p>"
response.end
end if
end if

%>
<!--链接ACCESS数据库-->
<div align="center"><span class="style1">
<%
set rs=server.createobject("adodb.recordset")
sql="select * from ok order by time desc"
rs.open sql,conn,1,1
dim totalPut
dim CurrentPage
dim TotalPages
dim i
const MaxPerPage=9
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.CacheSize = MaxPerPage
if not isempty(request("page")) then
currentPage=cint(reques

是用来做判断的,意思是不是记录头也不是记录尾。
在查询数据库时这句话起到判断记录集是否为空,如果为空not(rs.bof and rs.eof)就是假值。程序就会不做下面的动作。如果没有这句话,当遇到记录为空的情况的时候,下面仍然输出就会使程序出错,无法运行。

其中rs.bof是记录集rs的记录头,rs.eof是记录集rs的记录尾.

not(rs.bof and rs.eof)
这是判断数据库是否有数据
rs.bof 文件到头部
rs.eof 文件到尾部
又是头部又是尾部那不就是没有数据了吗?