关于sql的一个小疑问,大侠帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/13 01:51:10
sql="SELECT TOP 20 * FROM infoTT where shijian between '"&date()-1&"' and '"&date()&"' order by N_Number"
rs.open sql,conn,1,1
iCount=cint(rs.recordcount)'获得总记录数
For i=0 to 19
if i < iCount then
Response.Write rs("N_Name")
else
Response.Write "暂无"
end if
rs.movenext
next

我想显示infoTT表中今天的前二十名的用户姓名,并且当表中今天无用户信息时显示20个“暂无”,当用户数不足20名时

不足的补充显示“暂无”。
但是当我测试时发现错误,错误提示为:“BOF 或 EOF 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一

个当前的记录。”
我发现是因为今天infoTT表中没有用户的信息,但是它应该显示为“暂无”字样啊,这是怎么回事,哪儿设计的错误呢还

是SQL语句有误?我是菜鸟,请大侠赐教,谢谢!

今天的话应该是这样吧。
sql="SELECT TOP 20 * FROM infoTT where shijian = '"&date()&"' order by N_Number"

下面应该这样吧
iCount=cint(rs.recordcount)'获得总记录数

For i=0 to 19
if i < iCount then
Response.Write rs("N_Name")
rs.movenext
else
Response.Write "暂无"
end if
next

<%
sql="SELECT TOP 20 * FROM infoTT where shijian between '"&date()-1&"' and '"&date()&"' order by N_Number"
rs.open sql,conn,1,1
For i=0 to 19
if rs.eof then
Response.Write rs("暂无")
else if not rs.eof then
Response.Write(rs("N_Name"))
rs.movenext
End If
end if
next

set rs=nothing
conn.close
set conn=nothing
%>

rs.movenext 出错了。
你都没有记录,如何让他movenext
For i=0 to 19
if i < iCount then
{
Response.W