急!!ASP与两表的存储过程问题
表:choose(Title,studentid,posttime,choosetime,classroom,week,xingqi,jieci)
表:physics(title,exnus)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<%Dim title,stuid,classroom,week,xingqi,jieci,sum
''''''实验名称,学号,教室,周次,星期,节次,验证码'''''''''''
title=request.querystring("title")
stuid = trim(session("student_id")) '从session中读取学号
classroom=request.querystring("classroom")
week=request.form("week")
xingqi=request.form("xingqi")
jieci=request.form("less")
sum=week+xingqi+jieci
%>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<%''''''求实现以下ASP的功能的存储过程和ASP的执行代码.''''''''
sql="SELECT * FROM choose where studentid='"& stuid &"' Order By choosetime Desc"
Set Rs = Conn.Execute(sql)
sql4="SELECT count(*) as limit FROM choose where studentid='"& stuid &"' "
Set Rs4 = Conn.Execute(sql4)
if rs4("limit")>=4 then
Response.Write "<h2>你预约的实验已经达到要求,不能再选!</h2>"
else
sql2="SELECT count(*) as lim FROM choose where studentid='"& stuid &"' and week='"& week &"' "
Set Rs2 = Conn.Execute(sql2)
if rs2("lim")>=2 then
Response.Write "<h2>本周你预约的实验已经达到两个,请另选时间!</h2>"
else
sql5="SELECT exnus FROM physics where title='"& title &"' "
Set Rs5 = Conn.Execute(sql5)
if rs2("lim")>=rs5("exnus") then
Response.Write "<h2>本日该实验已经预约完毕,请另选时间!</h2>"
else
a=false
b=false
rs.movefirst
do while not rs.eof
if rs("title") = request.querystring("title") then
a=true
end if
if rs("choosetime") = sum then
b=true
end if
rs.movenext
loop
if a=true then
Response.Write "<h2>该实验你已预约!</h2>"
else
if b=true then
Response.Write "<h2>该时间段你已预约实验!</h2>"
else
if a=false and b=false then
sql3="INSERT INTO choose (Title,studentid,posttime,choosetime,classroom,week,xingqi,jieci) VALUES('" & title & "','" & stuid & "','"& now() &"','" & sum & "','" & classroom & "','" & week & "','" & xingqi & "','" & jieci & "')"
Conn.Execute(sql3)
Response.Write "<h2>实验预约成功!</h2>"
else
Response.Write "<h2>实验预约无法预约!</h2>"
end if
end if
end if
end if
end if
end if
rs.close
set rs = nothing
%>