大家看看这段asp程序对吗?怎么就不能更新呢
来源:百度知道 编辑:UC知道 时间:2024/09/23 10:47:59
set rs=Server.Createobject("adodb.recordset")
rs.open "select * from Dv_user where UserID='"&UserID&"'",conn,1,3
rs("yucun")=rs("yucun")+CInt(total_fee)
rs.update
rs.close
set rs=nothing
rs.open "select * from Dv_user where UserID='"&UserID&"'",conn,1,3
rs("yucun")=rs("yucun")+CInt(total_fee)
rs.update
rs.close
set rs=nothing
定义一下userid
userid=request.form("userid")
set rs=Server.Createobject("adodb.recordset")
rs.open "select * from Dv_user where UserID="&UserID,conn,1,3
rs("yucun")=rs("yucun")+CInt(total_fee)
rs.update
rs.close
set rs=nothing
为什么不用下面的形式呢:
sql="update Dv_user set yunchuan="&rs("yucun")+CInt(total_fee) &" where UserID='"&UserID&"'"
conn.execute(sql)
嗯,楼上的写法是很好的,不过,有点小问题,不存在rs("yucun")
所以代码写为:
sql="update Dv_user set yunchuan=yunchuan & "&CInt(total_fee) &" where UserID='"&UserID&"'"
conn.execute sql
以上代码为Access数据库,要是MSsql数据库
写为
sql="update Dv_user set yunchuan=yunchuan + "&CInt(total_fee) &" where UserID='"&UserID&"'"
conn.execute sql
要是回答的内容有问题,或认为不妥,请发送百度消