如何知道记录是否是最后一次

How to know if record is last

所以我在 SQL 中有这个查询。我知道我是否知道该记录是否是记录集中的最后一个:

sql = SELECT * FROM table WHERE RID = 27
Set rs=Conn.Execute(sql)

If not rs.EOF Then

   iID = rs("RID")
   If iID = LAST Then response.write ("this is last record") End If

End If
Conn.Close
Set Conn = Nothing

有什么办法吗?

不确定为什么需要这样做,但您可以这样做:

sql = SELECT * FROM table WHERE RID = 27
Set rs=Conn.Execute(sql)

If not rs.EOF Then

   rs.MoveNext
    If rs.EOF Then
       response.write ("this is last record") 
    End If

End If
Conn.Close
Set Conn = Nothing

考虑到您查询的性质,您似乎只会得到 1 行,所以这似乎毫无意义。

<%
sql = "SELECT MAX(RID) FROM table "
Set rs=Conn.Execute(sql)

isLast = "no records"
If not rs.BOF Then
 if rs(0) = 27 then '' 27 or somone else for your taste 
    ifLast = "last record"
 else
    ifLast = "not last record"
 end if  
End If

Response.Write isLast

Conn.Close
Set Conn = Nothing
%>