中草药杂志英文版:ASP初学者,请教高手!

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/06 11:36:00
关于调出用户列表!请高手指教!
我的数据库:user表中有userid(用户登陆ID);usercount(用户剩余点数)
现在我想做个用户消费排名列表,请问如何写?排列出前10名!
请帮忙写下详细的调出写法!谢谢了
谢谢你,我是刚开始学,对语句写法还不熟,可以写的全些吗?开头和结尾!谢谢了

<!-- #include file =\"conn.asp\" -->
<%
set rs=server.createobject(\"adodb.recordset\")
str=\"Select top10 userid,username from user order by usercount asc \"
rs.open str,conn,1,2,1
if not rs.bof and not rs.eof then
\'判断有无符合条件的数据
for i=1 to rs.recordcount
if not rs.bof and not rs.eof then
\'写出数据
response.write i&\"、\"&rs(\"userid\") & \"<br>\"
rs.movenext
else
exit for
end if
next
else
response.write \"对不起,没有任何数据在数据库表中\"
end if
rs.close
conn.close

%>
到此次程序已经结束,conn.asp为连接数据库的页面,如有任何问题,可以email我,我的电子信箱地址:sdxy@zj.com

sql="Select top10 userid,username from user order by usercount asc "
rs.open sql,conn,3,3
if not rs.eof then
i=0
response.write "排行榜"
do while not rs.eof
i=i+1
response.write "<br>"&i&"、"&rs("userid")
rs.movenext
loop
end if
rs.close

如果初始点数一致的话:
Select top10 userid,username from user order by usercount asc

select top 10 * from [表名] order by usercount

用索引查询关键字