取存储过程output的取

2年前 (2022) 程序员胖胖胖虎阿
217 0 0

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);//定义值接收

版权声明:程序员胖胖胖虎阿 发表于 2022年9月6日 上午10:00。
转载请注明:取存储过程output的取 | 胖虎的工具箱-编程导航

相关文章

暂无评论

暂无评论...