标签:style blog http io ar color sp on div
建立存储过程:
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER proc [dbo].[likefilm] @uid int, @fid int, @error int, @result int output as begin transaction update dbo.Film set LikeCount=LikeCount+1 where Id=@fid declare @likeid nvarchar(500) set @likeid=(select LikeId from dbo.Users where Id=@uid) if(@likeid=‘0‘) begin update dbo.Users set LikeId=cast(@fid as nvarchar(50))+‘|‘ where id=@uid end else begin update dbo.Users set LikeId=cast(@fid as nvarchar(50))+‘|‘+LikeId where id=@uid end set @result=1 set @error=@error+@@error if(@error>0) begin rollback transaction end else begin commit transaction end
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);
标签:style blog http io ar color sp on div
原文地址:http://www.cnblogs.com/sysoft/p/4109007.html