急!!ASP与两表的存储过程问题

cain2001 2005-04-17 03:59:40
表: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
%>
...全文
104 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
SELECT count(*) as limit FROM choose where studentid='"& stuid &"' "
举个例子,拿这个来说

stuid是变量声明要在
CREATE PROCEDURE dbo.picdisplay
@struid nvarchar(50)
as
declare @limit int
select @limit=count(*) from choose where studentid=@stuid 这么写的
  • 打赏
  • 举报
回复
set rs=server.createobject("adodb.recordset")
set MyCommand=server.createobject("adodb.command")
Set MyCommand.ActiveConnection=conn
MyCommand.CommandType=4
MyCommand.CommandText="picdisplay"
Set MyParam=MyCommand.CreateParameter("foldernum",3,1,4,0)
MyCommand.Parameters.Append Myparam
Set MyParam=MyCommand.CreateParameter("id",3,1,4,user_id)
MyCommand.Parameters.Append Myparam
Set MyParam=MyCommand.CreateParameter("page",3,1,4,page)
MyCommand.Parameters.Append Myparam
Set MyParam=MyCommand.CreateParameter("totalpage",3,2,4)
MyCommand.Parameters.Append Myparam
MyCommand.Execute
rs.open MyCommand,,3,3
if not rs.eof then
count=MyCommand("totalpage")
maxshow=2
str=display(rs,maxshow)
end if
rs.close
set rs=nothing
datapagebreak=str

这个是我程序的调用
  • 打赏
  • 举报
回复
刘银华你说话太不地道了,你发短消息给我的,本来我没准备回答你的帖子的,你发短消息了,我就帮你顶了一下的,我说我不想去测试你那个问题的,也跟你说了,我有什么对不住你的地方么??你想不想看看你平常都是怎么回答别人的问题的??

to 楼主,我可以把我写的存储过程帖出来,不过不是你要的,论坛是解决问题不是帮人做东西的,有什么问题可以探讨,帮你的程序改成存储过程又对你有啥好处的??感觉就跟考试作弊一样的事情

CREATE PROCEDURE dbo.picdisplay
@foldernum int,
@id int,
@page int,
@totalpage int output
AS
declare @thepage int
declare @pagenum int
declare @sql nvarchar(200)
set @thepage=(@page-1)*4
if @foldernum=0
begin
set @sql='select top 4 * from pic where id='
+cast(@id as nvarchar(30)) +'and thepicid not in
(select top '+cast(@thepage as nvarchar(30))+'
thepicid from pic where id='+cast(@id as nvarchar(30))+'
order by thepicid) order by thepicid'
exec sp_executesql @sql
select @pagenum=count(*) from pic where id=@id
select @totalpage=@pagenum/4+1
end
else
if @foldernum=1
begin
set @sql='select top 4 * from pic where id='
+cast(@id as nvarchar(30)) +'and share=1 and thepicid not in
(select top '+cast(@thepage as nvarchar(30))+'
thepicid from pic where id='+cast(@id as nvarchar(30))+' and share=1
order by thepicid) order by thepicid'
exec sp_executesql @sql
select @pagenum=count(*) from pic where id=@id and share=1
select @totalpage=@pagenum/4+1
end
else
if @foldernum=2
begin
set @sql='select top 4 * from pic where id='
+cast(@id as nvarchar(30)) +'and foldernum=0 and thepicid not in
(select top '+cast(@thepage as nvarchar(30))+'
thepicid from pic where id='+cast(@id as nvarchar(30))+' and foldernum=0
order by thepicid) order by thepicid'
exec sp_executesql @sql
select @pagenum=count(*) from pic where id=@id and foldernum=0
select @totalpage=@pagenum/4+1
end
else
begin
set @sql='select top 4 * from pic where id='
+cast(@id as nvarchar(30)) +'and foldernum='+cast(@foldernum as nvarchar(30))+' and thepicid not in
(select top '+cast(@thepage as nvarchar(30))+'
thepicid from pic where id='+cast(@id as nvarchar(30))+' and foldernum='+cast(@foldernum as nvarchar(30))+'
order by thepicid) order by thepicid'
exec sp_executesql @sql
select @pagenum=count(*) from pic where id=@id and share=1
select @totalpage=@pagenum/4+1
end
GO
ryuginka 2005-04-17
  • 打赏
  • 举报
回复
给个建议:
针对你程序中那么多的判断。你可以在存储过程里面用一个返回值FLAG来返回,然后传入参数,返回返回值,
在程序中对这个返回值进行处理。

就是把你的那些SQL语句都放到一个存储过程里面。、执行
ryuginka 2005-04-17
  • 打赏
  • 举报
回复
TO liuxiaoyi666(兔子)
很讨厌 你的这种帮人解决问题的语气。
上次我的问题你不但没有解决。而且害我浪费100分。
cain2001 2005-04-17
  • 打赏
  • 举报
回复
求存储过程的程序源码和ASP源码
leifen 2005-04-17
  • 打赏
  • 举报
回复
使用ADO对象模型,用Connection对象
sun8087 2005-04-17
  • 打赏
  • 举报
回复
关注一下,那个朋友能贴出来。

asp如何调用存贮过程的。以前项目还没有接触过,学习一下
cain2001 2005-04-17
  • 打赏
  • 举报
回复
up
  • 打赏
  • 举报
回复
我给你翻译我也懒得检查的,还是哪有不懂的问吧

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧