数组索引越界

来源:百度知道 编辑:UC知道 时间:2024/06/24 16:50:05
技术信息(用于支持人员)

错误类型:
Request 对象, ASP 0105 (0x80004005)
数组索引越界。
/localhost/ftproot/简单考试系统/result.asp, 第 37 行

程序如下:
sql="select * from test"
Set rs = conn.Execute( sql )
ycorrect=0
rsCount=0
'给出正确答案并评分
Response.Write "正确答案:"
Do while not rs.eof
Response.Write rs("ans")
rsCount=rsCount + 1
if Request.Form(rsCount)=rs("ans") then
ycorrect=ycorrect + 1
end if
rs.movenext
loop

嗯,都有些什么变量通过表单传过来

出错的是这句:

if Request.Form(rsCount)=rs("ans") then

Request.form中的传递过来的个数不太可能与记录集的个数一样多,所以就数组索引越界了

if Request.Form("你传递进来的变量名")=rs("ans") then

对回答的内容有问题,或认为不妥,百度消息我。
(在消息的内容里加上问题的网址哦)

Request.Form是从0开始的