要ASP的 会员登陆后执行某操作后扣除点数,点数不够不能操作的代码

来源:百度知道 编辑:UC知道 时间:2024/06/18 10:41:41
会员表:User 字段name pass count(点数)

执行操作的写入另外一表SendMsg
写入字段Phone后 自动扣除User表中对应这个用户name 的count点数1点

rs("count")=rs("count")-1

登陆成功的同时
将rs("count")减1
如果是字符串型 rs("count")=clng(rs("count"))-1
数字型 rs("count")=rs("count")-1

'方法一
变量=request.Form(key)
set rs=server.CreateObject("ADODB.recordset")
exec="insert into SendMsg [Phone] values('" & 变量 &"')"
conn.execute exec
conn.execute("update User set count=count-1")

'方法二
变量=request.Form(key)
set rst=server.CreateObject("ADODB.recordset")
rst.open "SendMsg",conn,1,3
rst("Phone")=变量
rst.addnew
N=rst("username")
rst.update
rst.close
set rs=server.CreateObject("ADODB.recordset")
sql="select count from user where name='" & N & "'"
rs.open sql,conn,1,3
rs("count")=rs("count")-