+ -
当前位置:首页 → 问答吧 → asp使用form表单post提交,处理页面得到form.count一直是0。求救啊。。

asp使用form表单post提交,处理页面得到form.count一直是0。求救啊。。

时间:2011-11-20

来源:互联网

<form action="exStudentAdd.asp" name="frmAddstudent" method="post" onSubmit="return checkFrm()">
这个是前面的form表单提交的属性。。
提交过来之后取得count的值一直是0,代码如下。

91 str = "select * from stutable where stuid = '" & Request.Form("stuid") &"'"
92 Response.Write(str & Request.Form.count)
93 set objRs=Server.CreateObject("ADODB.RECORDSET")
94 objRs.open str,conn
95 if Not(objRs.EOF or objRs.BOF) then
96 errOccur("学号已经存在")
97 else
98 set ndRs = Server.CreateObject("ADODB.RECORDSET")
99 ndRs.LockType=2
100 ndRs.open "stutable",conn
101 ndRs.addnew
102 for i=1 to 16
103 response.Write(Request.Form(i))
104 if Not Request.Form(i) = "" then
105 ndRs.fields(i-1) = Request.Form(i)
106 end if
107 next
108 ndRs.update

在显示字符串的时候发现显示为select * from stutable where stuid = '',Request.Form("stuid")没有得到。
然后在第103行报错说下标越界。。报了80004005错误。。

!!!最最郁闷的是,报错完之后查询数据库,发现,居然插入数据成功了。。。求解释啊。。怎么办

作者: yiwen028   发布时间: 2011-11-20

Request.form 使用不对:

Request.Form(Parameter)[(Index).Count]

填写在HTML的表单中所有的数据的集合。Parameter是在HTML表单中某一元素的名称。当某一参数具有不止一个值(比如,当在<SELECT>中使用MULTIPLE属性时)时,使用Index。当某一参数具有多值时,Count指明多值个数。

既然出错是在103行,而插入语句又是在这之前,那数据当然已经插入到数据库了.

作者: qianjin036a   发布时间: 2011-11-20