小问题,帮个忙!!!

era 2001-07-13 09:34:24
<%set rs=Server.CreateObject("ADODB.Recordset")
sql="select 用户名,count(用户名) as num from test group by 用户名 order by num desc"
rs.open sql,conn,1,1
dim arrNum
for i=0 to 9
arrNum(i)=rs("num")
rs.movenext
next
%>
源代码如上,我要把rs("num")中内容传入arrNum(i)中,但总是抱错
Microsoft VBScript runtime error '800a000d'

Type mismatch
该如何改。
...全文
62 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wybm 2001-07-13
  • 打赏
  • 举报
回复
这样写是不对的,如果数据库里没有记录或者记录的条数少于己于10条时就会出错,所以应该这样写:
<%set rs=Server.CreateObject("ADODB.Recordset")
sql="select 用户名,count(用户名) as num from test group by 用户名 order by num desc"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "No Record"
else
dim arrNum(9)
dim Icounter
Icounter=1
for i=0 to 9
if Icounter>rs.recordcount then
exit for
end if
arrNum(i)=rs("num")
rs.movenext
Icounter=Icounter+1
next
end fi
%>
Tyro 2001-07-13
  • 打赏
  • 举报
回复
为什么好多人都在表现层进行数据层的操作呀,大家都不用三层结构吗?
tripofdream 2001-07-13
  • 打赏
  • 举报
回复
<%set rs=Server.CreateObject("ADODB.Recordset")
sql="select 用户名,count(用户名) as num from test group by 用户名 order by num desc"
rs.open sql,conn,1,1
dim arrNum(9)
for i=0 to 9
arrNum(i)=rs("num")
rs.movenext
next
%>

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧