日期:2014-05-17 浏览次数:20573 次
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER proc [dbo].[Up_CheckManagerSession]
@userId varchar(20),
@ItemUrl varchar(50)
as
declare @i int ;
declare @ItemList varchar(300);
declare @ItemId varchar (10)
select @ItemId=ItemId from TR_Item where ItemUrl=@ItemUrl
select @ItemList=ItemList from ManagerTb where UserId=@userId
declare @sql nvarchar(3000)
declare @ii int
set @sql ='select @i= count(1) from ManagerTb where userId='''+@userId+''' and '''+@ItemId+''' in('+@ItemList+')'
exec sp_executesql @sql ,N'@i int out',@ii out
SqlCommand cmd = new SqlCommand("Up_CheckManagerSession", con); //调用存储过程
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
cmd.Parameters.Add("@ItemUrl", patp);
cmd.Parameters.Add("@userId", context.Session["ManagerId"].ToString());
cmd.Parameters.Add("@ii", "").Direction = ParameterDirection.Output;//获取存储过程的返回值
cmd.ExecuteNonQuery();
string value = cmd.Parameters["@ii"].Value.ToString();//把返回值赋值给value