asp 用session变量查找表内记录!急!!!

来源:百度知道 编辑:UC知道 时间:2024/05/13 10:58:11
表:xuexiao anclass nclass title
1 1 55
1 2 52
2 3 43
2 4 56
title是数值型
变量:
session("anclass")="1"
session("nclass")="2"
session("title")="25"
现在要求生成一个人数减少的表以后,把剩余人数更新,就是xuexiao表中title的值减去session("title")
<%
If session("anclass")<>"" and session("nclass")<>"" and session("title")<>"" Then
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from renshu "
rs.open sql,conn,1,3
rs.addnew
rs("anclass")=session("anclass")
rs("nclass")=session("nclass")
rs("shuliang")=session("title")

rs.update

sql="select * from xuexiao where anclass =session("anclass") and nclass =session("nclass")"

你再添加一条的时候这个rs要关闭
在后面update的时候要重新set一个Server.CreateObject("ADODB.Recordset")

rs.update

sql="select * from xuexiao where anclass =session("anclass") and nclass =session("nclass")"

rs("title")=rs("title")-session("title")

----------------------------------
.........
你如果前面的rs没有关闭的话.用Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.open sql,conn,1,3
rs1("title")=rs("title")-session("title")

rs1.update
rs1.close

这样..才行的.不能直接用一个的.