处理个ASP的数据库输出问题!

来源:百度知道 编辑:UC知道 时间:2024/05/28 23:03:35
怎样限制这里的数据库输出数量!请高手指导!
<%sql="select * from article where content like
'%"&rs("about")&"%' and newsid <> "&rs("newsid")&"
order by dateandtime DESC"
set rs2=server.createobject("adodb.recordset")
rs2.open sql,conn,1,1
do while not rs2.eof
%>

用select top 数字 * from 表名……
可以只提取前几条,数字是多少就是几条,然后做do while循环。

1楼的做法可以实现.

还有种办法及是设置一个变量i
<%i=0
do while not rs2.eof
response.write"第"&i+1&"次<br>"
if i>5 then
exit do while
end if
rs2.movenext
loop
%>