dkSql="select RecTime from Record201412 where worKNo=0002 and datediff(d,'"&dakadate&"',recdate)=0 order by id desc"
rsDaka.open dkSql,con,1,3
z=0
if not rsDaka.eof then
do while not rsDaka.eof
TimeArr=rsDaka("RecTime")’ 查询得来的结果是一个数据集,字段为datetime类型
rsDaka.movenext
loop
For z=Lbound(TimeArr) to Ubound(TimeArr) ‘出错的那一行
if TimeArr(z)<=800 then
else if TimeArr(z)>800 and TimeArr(z)<=1000 then
chidao=chidao+1
else if TimeArr(z)>1000 and TimeArr(z)<=1200 then
zaotui=zaotui+1
else if TimeArr(z)>1200 and TimeArr(z)<=1400 then
else if TimeArr(z)>1400 and TimeArr(z)<=1730 then
chidao=chidao+1
end if
end if
end if
end if
end if
next
end if
7 个解决方案
#1
TimeArr 不是一个数组,将它弄成数组就成
#2
if not rsDaka.eof then
do while not rsDaka.eof
TimeArr [z]=rsDaka("RecTime")’ 查询得来的结果是一个数据集,字段为datetime类型
rsDaka.movenext
z=z+1
loop
do while not rsDaka.eof
TimeArr [z]=rsDaka("RecTime")’ 查询得来的结果是一个数据集,字段为datetime类型
rsDaka.movenext
z=z+1
loop
#3
dim chidao,zaotui,zz,TimeArr(),z
zaotui=0
chidao=0
zz=0
z=0
set rsDaka=server.CreateObject("adodb.recordset")
'dkSql="select RecTime from Record"&yuefen&" where worKNo="&worKNo&" and datediff(d,'"&dakadate&"',recdate)=0 order by id desc"
dkSql="select RecTime from Record"&yuefen&" where worKNo="&worKNo&" and recdate='2014-12-1' order by id desc"
rsDaka.open dkSql,con,1,3
if not rsDaka.eof then
do while not rsDaka.eof
TimeArr(z)=rsDaka("RecTime")
z=z+1
rsDaka.movenext
loop
For z=Lbound(TimeArr) to Ubound(TimeArr)
Response.Write TimeArr(z) & "<br>"
if left(TimeArr(z),2)<=08 then
else if left(TimeArr(z),2)>08 and left(TimeArr(z),2)<=10 then
chidao=chidao+1
else if left(TimeArr(z),2)>10 and left(TimeArr(z),2)<=12 then
zaotui=zaotui+1
else if left(TimeArr(z),2)>12 and left(TimeArr(z),2)<=14 then
else if left(TimeArr(z),2)>14 and left(TimeArr(z),2)<=18 then
chidao=chidao+1
end if
end if
end if
end if
end if
next
end if
Next
#4
还是照常报错 Microsoft VBScript 运行时错误 错误 '800a0009' 下标越界
#5
好久没看ASP了,手误 应该是TimeArr
(z)=rsDaka("RecTime")
不应该是中括号,应该是小括号。
下面的循环
For z=0 to Ubound(TimeArr)
不应该是中括号,应该是小括号。
下面的循环
For z=0 to Ubound(TimeArr)
#6
如果还是不行,再加个redim处理
set rsDaka=server.CreateObject("adodb.recordset")
dkSql="select RecTime from Record201412 where worKNo=0002 and datediff(d,'"&dakadate&"',recdate)=0 order by id desc"
rsDaka.open dkSql,con,1,3
z=0
'获取数组的大小
if not rsDaka.eof then
do while not rsDaka.eof
z=z+1
rsDaka.movenext
loop
'重定义数组
REDIM TimeArr(z)
'数组赋值
z=0
if not rsDaka.eof then
do while not rsDaka.eof
TimeArr(z)=rsDaka("RecTime")’ 查询得来的结果是一个数据集,字段为datetime类型
rsDaka.movenext
loop
For z=Lbound(TimeArr) to Ubound(TimeArr) ‘出错的那一行
if TimeArr(z)<=800 then
else if TimeArr(z)>800 and TimeArr(z)<=1000 then
chidao=chidao+1
else if TimeArr(z)>1000 and TimeArr(z)<=1200 then
zaotui=zaotui+1
else if TimeArr(z)>1200 and TimeArr(z)<=1400 then
else if TimeArr(z)>1400 and TimeArr(z)<=1730 then
chidao=chidao+1
end if
end if
end if
end if
end if
next
end if
set rsDaka=server.CreateObject("adodb.recordset")
dkSql="select RecTime from Record201412 where worKNo=0002 and datediff(d,'"&dakadate&"',recdate)=0 order by id desc"
rsDaka.open dkSql,con,1,3
z=0
'获取数组的大小
if not rsDaka.eof then
do while not rsDaka.eof
z=z+1
rsDaka.movenext
loop
'重定义数组
REDIM TimeArr(z)
'数组赋值
z=0
if not rsDaka.eof then
do while not rsDaka.eof
TimeArr(z)=rsDaka("RecTime")’ 查询得来的结果是一个数据集,字段为datetime类型
rsDaka.movenext
loop
For z=Lbound(TimeArr) to Ubound(TimeArr) ‘出错的那一行
if TimeArr(z)<=800 then
else if TimeArr(z)>800 and TimeArr(z)<=1000 then
chidao=chidao+1
else if TimeArr(z)>1000 and TimeArr(z)<=1200 then
zaotui=zaotui+1
else if TimeArr(z)>1200 and TimeArr(z)<=1400 then
else if TimeArr(z)>1400 and TimeArr(z)<=1730 then
chidao=chidao+1
end if
end if
end if
end if
end if
next
end if
#7
数组必须提前定义大小
Dim arr(3)
或者是一开始不定义,而在随后的程序里计算出长度后,再动态定义
//一开始不知道具体的长度
Dim arr()
//经过一些运算后,产生了长度
myLength=xxxObj.length()
//然后再重新设定arr长度
Redim arr(myLength)
//然后开始赋值
for i=0 to myLength
arr(i)=i
next
Dim arr(3)
或者是一开始不定义,而在随后的程序里计算出长度后,再动态定义
//一开始不知道具体的长度
Dim arr()
//经过一些运算后,产生了长度
myLength=xxxObj.length()
//然后再重新设定arr长度
Redim arr(myLength)
//然后开始赋值
for i=0 to myLength
arr(i)=i
next
#1
TimeArr 不是一个数组,将它弄成数组就成
#2
if not rsDaka.eof then
do while not rsDaka.eof
TimeArr [z]=rsDaka("RecTime")’ 查询得来的结果是一个数据集,字段为datetime类型
rsDaka.movenext
z=z+1
loop
do while not rsDaka.eof
TimeArr [z]=rsDaka("RecTime")’ 查询得来的结果是一个数据集,字段为datetime类型
rsDaka.movenext
z=z+1
loop
#3
dim chidao,zaotui,zz,TimeArr(),z
zaotui=0
chidao=0
zz=0
z=0
set rsDaka=server.CreateObject("adodb.recordset")
'dkSql="select RecTime from Record"&yuefen&" where worKNo="&worKNo&" and datediff(d,'"&dakadate&"',recdate)=0 order by id desc"
dkSql="select RecTime from Record"&yuefen&" where worKNo="&worKNo&" and recdate='2014-12-1' order by id desc"
rsDaka.open dkSql,con,1,3
if not rsDaka.eof then
do while not rsDaka.eof
TimeArr(z)=rsDaka("RecTime")
z=z+1
rsDaka.movenext
loop
For z=Lbound(TimeArr) to Ubound(TimeArr)
Response.Write TimeArr(z) & "<br>"
if left(TimeArr(z),2)<=08 then
else if left(TimeArr(z),2)>08 and left(TimeArr(z),2)<=10 then
chidao=chidao+1
else if left(TimeArr(z),2)>10 and left(TimeArr(z),2)<=12 then
zaotui=zaotui+1
else if left(TimeArr(z),2)>12 and left(TimeArr(z),2)<=14 then
else if left(TimeArr(z),2)>14 and left(TimeArr(z),2)<=18 then
chidao=chidao+1
end if
end if
end if
end if
end if
next
end if
Next
#4
还是照常报错 Microsoft VBScript 运行时错误 错误 '800a0009' 下标越界
#5
好久没看ASP了,手误 应该是TimeArr
(z)=rsDaka("RecTime")
不应该是中括号,应该是小括号。
下面的循环
For z=0 to Ubound(TimeArr)
不应该是中括号,应该是小括号。
下面的循环
For z=0 to Ubound(TimeArr)
#6
如果还是不行,再加个redim处理
set rsDaka=server.CreateObject("adodb.recordset")
dkSql="select RecTime from Record201412 where worKNo=0002 and datediff(d,'"&dakadate&"',recdate)=0 order by id desc"
rsDaka.open dkSql,con,1,3
z=0
'获取数组的大小
if not rsDaka.eof then
do while not rsDaka.eof
z=z+1
rsDaka.movenext
loop
'重定义数组
REDIM TimeArr(z)
'数组赋值
z=0
if not rsDaka.eof then
do while not rsDaka.eof
TimeArr(z)=rsDaka("RecTime")’ 查询得来的结果是一个数据集,字段为datetime类型
rsDaka.movenext
loop
For z=Lbound(TimeArr) to Ubound(TimeArr) ‘出错的那一行
if TimeArr(z)<=800 then
else if TimeArr(z)>800 and TimeArr(z)<=1000 then
chidao=chidao+1
else if TimeArr(z)>1000 and TimeArr(z)<=1200 then
zaotui=zaotui+1
else if TimeArr(z)>1200 and TimeArr(z)<=1400 then
else if TimeArr(z)>1400 and TimeArr(z)<=1730 then
chidao=chidao+1
end if
end if
end if
end if
end if
next
end if
set rsDaka=server.CreateObject("adodb.recordset")
dkSql="select RecTime from Record201412 where worKNo=0002 and datediff(d,'"&dakadate&"',recdate)=0 order by id desc"
rsDaka.open dkSql,con,1,3
z=0
'获取数组的大小
if not rsDaka.eof then
do while not rsDaka.eof
z=z+1
rsDaka.movenext
loop
'重定义数组
REDIM TimeArr(z)
'数组赋值
z=0
if not rsDaka.eof then
do while not rsDaka.eof
TimeArr(z)=rsDaka("RecTime")’ 查询得来的结果是一个数据集,字段为datetime类型
rsDaka.movenext
loop
For z=Lbound(TimeArr) to Ubound(TimeArr) ‘出错的那一行
if TimeArr(z)<=800 then
else if TimeArr(z)>800 and TimeArr(z)<=1000 then
chidao=chidao+1
else if TimeArr(z)>1000 and TimeArr(z)<=1200 then
zaotui=zaotui+1
else if TimeArr(z)>1200 and TimeArr(z)<=1400 then
else if TimeArr(z)>1400 and TimeArr(z)<=1730 then
chidao=chidao+1
end if
end if
end if
end if
end if
next
end if
#7
数组必须提前定义大小
Dim arr(3)
或者是一开始不定义,而在随后的程序里计算出长度后,再动态定义
//一开始不知道具体的长度
Dim arr()
//经过一些运算后,产生了长度
myLength=xxxObj.length()
//然后再重新设定arr长度
Redim arr(myLength)
//然后开始赋值
for i=0 to myLength
arr(i)=i
next
Dim arr(3)
或者是一开始不定义,而在随后的程序里计算出长度后,再动态定义
//一开始不知道具体的长度
Dim arr()
//经过一些运算后,产生了长度
myLength=xxxObj.length()
//然后再重新设定arr长度
Redim arr(myLength)
//然后开始赋值
for i=0 to myLength
arr(i)=i
next