统计每月网站访问量出错了,请高手进来看看!

caobin518 2005-06-07 06:40:29
我的设计过程为:
网站的访问统计,为了统计每天的访问量,我做的做法为,
for i=31 to 1 step -1
rs.open"select * from [table] where day(jointime)='"&i&"'",conn,1,1
......
next
问题出在:有些月份没有31号,导致程序出错
出错信息为:

Microsoft VBScript 编译器错误 错误 '800a03f6'

缺少 'End'

/iisHelp/common/500-100.asp,行242

Microsoft VBScript 运行时错误 错误 '800a005e'

无效使用 Null: 'round'

/data/list_day.asp,行42

结果改成:
for i=31 to 1 step -1
rs.open"select * from [table] where day(jointime)='"&i&"'",conn,1,1
if rs.recordcount=0 then exit for
......
next
还是出错。
...全文
169 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
超级大笨狼 2005-06-07
  • 打赏
  • 举报
回复
首先:
for i=31 to 1 step -1
rs.open。。。。

这种思路就是错的,不应该在循环中去打开rs,应该用一个语句返回整个纪录集,不要多次open.

尽晚打开数据库,尽早关闭之。

这个做法完全可以写成
select * from [table] order by day(jointime)
.....
目的是open一次。
逐行显示的时候再去和数字判断。
如果业务逻辑复杂,你不会写复杂的SQL,那么可以用getrows把纪录灌到数组来处理。

[尽晚打开数据库,尽早关闭之]

2,判断是否有该日期可以组合成类似:isdate("2005-2-31")判断如果false就跳过去。



zlj113 2005-06-07
  • 打赏
  • 举报
回复
试下 if rs.recordcount <1 then exit for
caobin518 2005-06-07
  • 打赏
  • 举报
回复
请高手进来看看!
caobin518 2005-06-07
  • 打赏
  • 举报
回复
还是不对,我把代码写详细点
for i=31 to 1 step -1
rs.open"select sum(num) as num1 from [table] where day(jointime)='"&i&"'",conn,1,1
if rs.recordcount=0 then exit for
......
next
这段代码是为了统计每月网站访问量,如果某一个月没有31号,就会出现错误:
Microsoft VBScript 编译器错误 错误 '800a03f6'

缺少 'End'

/iisHelp/common/500-100.asp,行242

Microsoft VBScript 运行时错误 错误 '800a005e'

无效使用 Null: 'round'

/data/list_day.asp,行42

zlj113 2005-06-07
  • 打赏
  • 举报
回复
提示用round不能为空那你判断下嘛

假设Z为你需要round的字段

select x,y,isnull(z,0) as z from [table] where day(jointime)='" & i & "'"
kc_ren 2005-06-07
  • 打赏
  • 举报
回复
为什么要那么写啊?
select * from [table] where day(jointime)='"&i&"

这样写 select day(jointime) from [table] 就可以了
caobin518 2005-06-07
  • 打赏
  • 举报
回复
自己再顶
caobin518 2005-06-07
  • 打赏
  • 举报
回复
高手呢?

28,406

社区成员

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

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