我有sqlCommand的以下参数.如何使其存入和存储存储过程的参数值.
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;
然后在执行命令后读取输出值:
// assumes that the parameter is a string and that it could possibly be null string value = Convert.IsDBNull(pInOut.Value) ? null : (string)pInOut.Value;