存贮过程是在SQL SERVER里已经写好的SQL代码文本方式,你在ASP或是其它C++,VB等程序调用它,下面的一个在ASP调用它的例子,你看看吧
Set cm.ActiveConnection = conn
cm.CommandText = "gameover_disc" '与Sql Server中建立的存储过程名称对应
cm.CommandType = 4 'CommandType表示存储过程
set p = cm.Parameters
p.Append cm.CreateParameter("@gameid",3,1) '下面为Command增加3 p.Append cm.CreateParameter("参数名,类型,方向,大小)
p.Append cm.CreateParameter("@win_money",3,2) gameid=rs("id")
cm("@gameid")=gameid -给参数赋值
cm.execute -执行存贮过程在数据库里你点击存贮程序,右键,新建存贮过程,代码的例子如下:CREATE PROCEDURE gameover_disc
@gameid int,
@mteam nvarchar(50),
@gteam nvarchar(50),
@mcount_people int output,
@gcount_people int output,
@mcount_money int output,
@gcount_money int output,
@win_money int output
as
declare @m_people int select @mcount_money=sum(money),@mcount_people=count(id) from football_bet where teamname=@mteam and gameid=@gameid
select @gcount_money=sum(money),@gcount_people=count(id) from football_bet where teamname=@gteam and gameid=@gameid
--select @mcount_people=count(id) from football_bet where teamname=@mteam and gameid=@gameid
--select @gcount_people=count(id) from football_bet where teamname=@gteam and gameid=@gameid
select @win_money=sum(getmoney) from football_bet where gameid=@gameid
GO:),希望你能看得明白。
Set cm.ActiveConnection = conn
cm.CommandText = "gameover_disc" '与Sql Server中建立的存储过程名称对应
cm.CommandType = 4 'CommandType表示存储过程
set p = cm.Parameters
p.Append cm.CreateParameter("@gameid",3,1) '下面为Command增加3 p.Append cm.CreateParameter("参数名,类型,方向,大小)
p.Append cm.CreateParameter("@win_money",3,2) gameid=rs("id")
cm("@gameid")=gameid -给参数赋值
cm.execute -执行存贮过程在数据库里你点击存贮程序,右键,新建存贮过程,代码的例子如下:CREATE PROCEDURE gameover_disc
@gameid int,
@mteam nvarchar(50),
@gteam nvarchar(50),
@mcount_people int output,
@gcount_people int output,
@mcount_money int output,
@gcount_money int output,
@win_money int output
as
declare @m_people int select @mcount_money=sum(money),@mcount_people=count(id) from football_bet where teamname=@mteam and gameid=@gameid
select @gcount_money=sum(money),@gcount_people=count(id) from football_bet where teamname=@gteam and gameid=@gameid
--select @mcount_people=count(id) from football_bet where teamname=@mteam and gameid=@gameid
--select @gcount_people=count(id) from football_bet where teamname=@gteam and gameid=@gameid
select @win_money=sum(getmoney) from football_bet where gameid=@gameid
GO:),希望你能看得明白。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货