如何在C#中获取存储过程的参数
现有存储过程:
create procedure ggg
@aa float=10.0,
@bb int=0 output,
@cc float=1.0 output
as
declare @sql nvarchar(4000)
set @sql= 'select @cc=count(*) from Pub_Dic_CorpType '
exec sp_executesql @sql,N '@cc float output ', @cc output
select @cc
set @bb=ceiling(@cc/@aa)
怎样在C#中将@bb 和 @cc获取到C#的变量中,然后在页面输出
[解决办法]
SqlCommand cmd = new SqlCommand( "ggg ", myConn);
cmd.CommandType = CommandType.StoredProcedure;
//输入值aa
SqlParameter a1 = new SqlParameter( "@aa ", SqlDbType.Float);
a1.Value=11;
cmd.Parameters.Add(a1);
//返回值 bb
SqlParameter bb = new SqlParameter( "@bb ", SqlDbType.Int,4);
bb.Direction = ParameterDirection.Output;
cmd.Parameters.Add(i);
cmd.ExecuteNonQuery();
string strReturn = bb.Value.ToString();