陪床难戒番外txt:asp批量添加数据的问题!

来源:百度文库 编辑:中科新闻网 时间:2024/04/30 04:26:36
要做一简单的asp系统,批量添加一组工人的年龄和工龄!
代码是:
set rs = server.CreateObject ("Adodb.recordset")
Num=request.form("userid").count
for i=1 to Num
sql = "select * from oblog_user where userid="&request.form("userid")(i)
rs.Open sql,conn,1,3
rs.update "xiaolunwen",'tempxiaolunwen'
rs.update "pingshi",'temppingshi'
rs.close
next

运行错误
Microsoft VBScript 编译器错误 (0x800A03EA)
语法错误
/blog/physics03.asp, line 18, column 23
rs.update "xiaolunwen",'tempxiaolunwen'
----------------------^
Phoenix59Sky朋友的方法二,出现这样的错误:
比如,要同时改写满足条件的4个员工的年龄(分别是31、32、33、34)、工龄(5、6、7、8),将数据写入数据表后,本应是年龄和工龄出现在每个员工的记录年龄和工龄字段里(如张三的年龄是31,工龄为5),现在出现的情况是每个员工的记录的每个字段下都有相同的4个数字((31,32,33,34\5,6,7,8))(如张三的年龄是31,32,33,34,工龄为5,6,7,8)(李四的年龄也是31,32,33,34,工龄为5,6,7,8),是什么原因?请帮助分析!

tempxiaolunwen和temppingshi的数据来自:
tempxiaolunwen=Request("xiaolunwen")
temppingshi=Request("pingshi")
xiaolunwen、pingshi来自录入页面的表单采集

希望QQ交流312753474

Phoenix59Sky朋友的方法一,出现这样的错误:
ADODB.Recordset (0x800A0E79)
对象打开时,不允许操作。

newlethe朋友的方法,也是出现这样的问题
ADODB.Recordset (0x800A0E79)
对象打开时,不允许操作。

方法一:
rs.update "xiaolunwen",'tempxiaolunwen'
rs.update "pingshi",'temppingshi'
改为:
rs("xiaolunwen")=tempxiaolunwen
rs("pingshi")=temppingshi
rs.update
方法二:
直接用conn语句试试,
所有代码改成:
Num=request.form("userid").count
for i=1 to Num
conn.execute("update [oblog_user] set xiaolunwen="&tempxiaolunwen&"',pingshi='"&temppingshi&" where userid="&request.form("userid")(i)
next

方法二的错误,你说得更具体一点好吧,比如说张三,李四同时符合要求,他们的年龄是....
我觉得这就不是代码本身的问题,是tempxiaolunwen和temppingshi的数据在赋值时算法出了问题

rs.update "xiaolunwen",'tempxiaolunwen'
rs.update "pingshi",'temppingshi'
改为:
rs.addnew()
rs("xiaolunwen")=tempxiaolunwen
rs("pingshi")=temppingshi
rs.update()