IN-OUT参数的SqlCommand [英] In-Out Parameter for SqlCommand

查看:220
本文介绍了IN-OUT参数的SqlCommand的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对SqlCommand的下列参数。我如何使它在国内外享有很高的存储过程的放慢参数值。

 的SqlCommand的MySqlCommand =新的SqlCommand(aspInsertZip code的MySqlConnection);
 mySqlCommand.CommandType = CommandType.StoredProcedure;
 mySqlCommand.Parameters.Add(@数据行,dataStringToProcess.ToString());
 

解决方案

  VAR引出线= mySqlCommand.Parameters.Add(@数据行,dataStringToProcess.ToString());
pInOut.Direction = ParameterDirection.InputOutput;
 

然后要你执行的命令后,读取输出值:

  //假定参数是一个字符串,它也可能会被空
字符串值= Convert.IsDBNull(pInOut.Value)?空:(串)pInOut.Value;
 

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;

这篇关于IN-OUT参数的SqlCommand的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆