取存储过程output的取

sql存储过程定义字段
@RetValue int out
as
 select @RetValue=xxxx  from .......

cs代码:
SqlCommand com = new SqlCommand("存储过程名",con对象);//建立SQL命令
com.CommandType = CommandType.StoredProcedure;//指定使用SQL存储过程
com.Parameters.Add("@RetValue", SqlDbType.Int).Direction = ParameterDirection.Output;//得到存储过程返回值

int rv = Convert.ToInt32(com.Parameters["@RetValue"].Value);//定义值接收

你可能感兴趣的:(取存储过程output的取)