.net 调用有返回值的存储过程
代码里:
SqlParameter[] paras = new SqlParameter[2];
paras[0] = new SqlParameter("@Email", email);paras[1] = new SqlParameter("@Value",SqlDbType.Int);
paras[1].Direction = ParameterDirection.ReturnValue;
SqlHelper.ExecuteNonQuery(ConfigService.MassMailingCon, CommandType.StoredProcedure, "Proc_IsExistEmail", paras);
int returnValue = (int)paras[1].Value;
SQL语句:
CREATE PROCEDURE Proc_IsExistEmail
@Email varchar(64),
@Value int =null out
AS
BEGIN
if(not exists(select 0 from MassMailingList where emailto =@Email))
return 0
else
return 1
END
注释:如果为ParameterDirection.ReturnValue 在存储过程里return value返回值,
如果为ParameterDirection.Output则要设置要设置输出参数 @Value的值