LCJ*_*LCJ 11 .net c# sql-server asp.net ado.net
我有SqlCommand的以下参数.如何进入和退出存储过程的参数值.
SqlCommand mySqlCommand = new SqlCommand("aspInsertZipCode", mySqlConnection);
mySqlCommand.CommandType = CommandType.StoredProcedure;
mySqlCommand.Parameters.Add("@DataRows", dataStringToProcess.ToString());
Run Code Online (Sandbox Code Playgroud)
Luk*_*keH 14
var pInOut = mySqlCommand.Parameters.Add("@DataRows", dataStringToProcess.ToString());
pInOut.Direction = ParameterDirection.InputOutput;
Run Code Online (Sandbox Code Playgroud)
然后在执行命令后读取输出值:
// assumes that the parameter is a string and that it could possibly be null
string value = Convert.IsDBNull(pInOut.Value) ? null : (string)pInOut.Value;
Run Code Online (Sandbox Code Playgroud)
SqlParameter有一个Direction枚举.设置此值.
然后用SqlCommand.Parameters.Add那个拿a SqlParameter.
参数方向:
http://msdn.microsoft.com/en-us/library/system.data.parameterdirection.aspx
然后ExecuteNonQuery通过Value从命令集中获取参数来调用(例如)之后将值拉出:
myCommand.Parameters["@paramName"].Value
不记得了,但我认为有一个字符串索引器.
或者,有一个班轮:
myCommand.Parameters.AddWithValue("@paramName", value).Direction = ParameterDirection.InputOutput;
| 归档时间: |
|
| 查看次数: |
32808 次 |
| 最近记录: |