ASP调用ACCESS数据库一个表里的某些数据,只显示前几条。

我要调用classid 3的数据在主页显示,只显示6条,应该怎么办。
下面是调用该数据的代码,该怎么修改。
<%set rs=conn.execute("select * from news where classid=3" )do while not rs.eof%> <tr> <td height="30" align="left" style="line-height:20px;letter-spacing:2px;"> <a href="newsinfo.asp?id=<%=rs("id")%>"><%=rs("title")%></a> </td> <td style="color:#FF0000;" align="right">[<%=rs("addtime")%>] </td> </tr> <% rs.movenextloop rs.closeset rs=nothing%>

第1个回答  2017-11-27

只选择前六条可否,

<%set rs=conn.execute("select top 6 * from news where classid=3" )do while not rs.eof%> <tr> <td height="30" align="left" style="line-height:20px;letter-spacing:2px;"> <a href="newsinfo.asp?id=<%=rs("id")%>"><%=rs("title")%></a> </td> <td style="color:#FF0000;" align="right">[<%=rs("addtime")%>] </td> </tr> <% rs.movenextloop rs.close set rs=nothing%>

请采纳!

第2个回答  2017-11-19
利用"目的" 和 "发的" 两个变量筛选SQL语句这么写:
Select 车次, 查询1.途经站点 as 发的, 查询2.途经站点 as 目的, 查询2.票价 from ((Select 车次, 途经站点 from 途径点表 where 途径车站='“+发的+"') as 查询1 inner Join (Select 车次, 途经站点, 票价 from 途径点表 where 途径车站='"+目的+"') as 查询2 on 查询1.车次=查询2.车次)
嵌套子查询
第3个回答  2017-11-30
set rs=conn.execute("select * from news where classid=3" )
修改成
set rs=conn.execute("select top 6 * from news where classid=3" )

第4个回答  2017-11-16
<%set rs=conn.execute("select * from news where classid=3" )do while not rs.eof%> 这一句改为
<%set rs=conn.execute("select top 6 * from news where classid=3" )do while not rs.eof%>
第5个回答  2014-06-26
select top 6 * from news where classid=3本回答被提问者采纳
相似回答