首页 > 代码库 > 存储过程简单调用(from www.sysoft.cc)
存储过程简单调用(from www.sysoft.cc)
建立存储过程:
set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoALTER proc [dbo].[likefilm]@uid int,@fid int,@error int,@result int outputasbegin transactionupdate dbo.Film set LikeCount=LikeCount+1 where Id=@fiddeclare @likeid nvarchar(500)set @likeid=(select LikeId from dbo.Users where Id=@uid)if(@likeid=‘0‘)beginupdate dbo.Users set LikeId=cast(@fid as nvarchar(50))+‘|‘ where id=@uidendelsebeginupdate dbo.Users set LikeId=cast(@fid as nvarchar(50))+‘|‘+LikeId where id=@uidendset @result=1set @error=@error+@@errorif(@error>0)begin rollback transactionendelsebegin commit transactionend
调用存储过程
SqlParameter error = new SqlParameter("error", 0); SqlParameter Uid = new SqlParameter("uid", Convert.ToInt32(uid)); SqlParameter Fid = new SqlParameter("fid", Convert.ToInt32(fid)); SqlParameter Resault = new SqlParameter("result", 0); Resault.Direction = System.Data.ParameterDirection.Output; SqlParameter[] pms = new SqlParameter[] {Uid,Fid,Resault,error}; int resault=0; DbHelperSQL.RunProcedure("likefilm", pms, out resault);
存储过程简单调用(from www.sysoft.cc)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。