+ -
当前位置:首页 → 问答吧 → 请帮我看看我这里循环插入那里错了?

请帮我看看我这里循环插入那里错了?

时间:2011-10-30

来源:互联网

if request("insert")<>"" then
 Do While Not rs.EOF
SQL="insert into table (xm,nj,cj) values ('"&Trim(Request("xm"))&"','"&Trim(Request("nj")(i))&"','"&Trim(Request("cj")(i))&"')"
conn.execute(xSQL)
  rs.movenext
  i=i+1
 loop
 rs.Close()
 Set rs = Nothing
end if



按提交后 提示:
下标越界 

/oakhinb.asp,行 20 

数组下标越界。 

用户提交界面的表格是这样的:姓名是固定的session信息, nj和 cj是 rs记录的循环输出,我现在想用户可以更改nj,cj后插入到另外一个新表.
用户名: xm 
nj cj
2 50
3 60
1 50
.
.
.
.




作者: dusttosky   发布时间: 2011-10-30

该回复于2011-10-30 14:10:38被管理员删除

  • 对我有用[0]
  • 丢个板砖[0]
  • 引用
  • 举报
  • 管理
  • TOP
  • hookee
  • 等 级:
  • 更多勋章
#2楼 得分:0回复于:2011-10-30 15:22:16
rs没有用到吧
VBScript code

if request("insert")<>"" then
    For i=0 To Request("cj").Count-1
        SQL = "insert into table (xm,nj,cj) values ('"&Trim(Request("xm"))&"','"&Trim(Request("nj")(i))&"','"&Trim(Request("cj")(i))&"')"
        conn.execute(xSQL)
    Next
end if

作者: zsy222ljh   发布时间: 2011-10-30

hookee 再请问一下,
<%do while not rs.eof%>
<input name="khxm"%"i"> 我这里赋名字对吗?
<%
rs.movenext
i=+1
loop
%>

作者: hookee   发布时间: 2011-10-30

HTML code

<%
i = 0
do while not rs.eof
%>
<input name="khxm<%=i%>">
<%
rs.movenext
i=+1
loop
%>


作者: dusttosky   发布时间: 2011-10-30