IN-OUT参数的SqlCommand参数、IN、OUT、SqlCommand

2023-09-03 01:26:04 作者:沵是涐一辈子的执着

我对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;
 
UAS协议说明

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;