关于数据存取

来源:百度知道 编辑:UC知道 时间:2024/07/02 13:51:33
a003字段存储的是一组id 是例如:22,23,24,
现在就是把22 和23 和24 分别取出来然后把table01中id=22.23.24的记录中的pay=1 然后把a003存到table02的a003中去 但是现在存在的问题是table01中的pay改变不了 没有显示程序错误
请高手指教!!!

for i=1 to len(a003)
n=mid(x,i,1)
if n="," then
i1=i1+1
end if
next

idd=split(a003,",")
for i2=1 to i1
id=trim(idd(i2-1))
set rp1=server.createobject("adodb.recordset")
sql="select * from table01 where id='"&id&"'"
rp1.open sql,conn,1,3
if not rp1.eof then
rp1("pay")=1
rp1.update
end if
next

set rp=server.CreateObject("adodb.recordset")
str="select * from table02"
rp.open str,conn,1,3
rp.addnew
rp("a001")=a001
rp("a002")=a002
rp("a003")=a003
rp("check")=check
rp("hid")=hid
rp("time1")=date()
rp.up

只能改第一条?这程序应该没错呀。
你输出这个看看,应该是输出3:
idd=split(a003,",")
response.write ubound(idd)
response.end
=====================================
你不把全部代码都贴出来,应该说清楚点啊!
“提交页面会出错”是指哪个页面?出的是什么错???
还有,你前面有没有把数据库里取出来的值赋给a003?
=====================================
那有可能是循环的问题,换一下看看:
idd=split(a003,",")
set rp1=server.createobject("adodb.recordset")
for i=0 to ubound(idd)
id=idd(i)
if id<>"" then
sql="select * from table01 where id='"&id&"'"
rp1.open sql,conn,1,3
if not rp1.eof then
rp1("pay")=1
rp1.update
end if
rp1.close
end if
next
set rp1=nothing
=======================================
table01 中 id 字段是字符型的吗?
如果不是,程序的sql语句就错了,应该是这样:
sql="select * from table01 where id="&id