本文介绍了SqlCommand 的 In-Out 参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I have the following parameter for SqlCommand. How do I make it to both in and out the paramter value for the Stored Procedure.
SqlCommand mySqlCommand = new SqlCommand("aspInsertZipCode", mySqlConnection);
mySqlCommand.CommandType = CommandType.StoredProcedure;
mySqlCommand.Parameters.Add("@DataRows", dataStringToProcess.ToString());
解决方案
var pInOut = mySqlCommand.Parameters.Add("@DataRows", dataStringToProcess.ToString());
pInOut.Direction = ParameterDirection.InputOutput;
And then to read the output value after you've executed the command:
// assumes that the parameter is a string and that it could possibly be null
string value = Convert.IsDBNull(pInOut.Value) ? null : (string)pInOut.Value;
这篇关于SqlCommand 的 In-Out 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!