怎么取存储过程的字符串
存储过程输出参数:@strMessage = 1,9,3,怎么在ADO。NET取得该字符串?
[解决办法]
SqlCommand Cmd ....
SqlParameter param=Cmd.Parameters.Add( "@strMessage ",SqlDbType.NVarChar,100);
param.Direction=ParameterDirection.Output;
Cmd.ExecuteNonQuery();
string strMessage = Cmd.Parameters[ "@strMessage "].Value.ToString();
[解决办法]
SqlCommand Cmd ....
SqlParameter param=Cmd.Parameters.Add( "@strMessage ",SqlDbType.NVarChar,100);
param.Direction=ParameterDirection.Output;
SqlDataReader dr = Cmd.ExecuteReader();
dr.Close(); // 对于 DataReader 得先关闭,才能获取输出参数河返回值
string strMessage = Cmd.Parameters[ "@strMessage "].Value.ToString();
[解决办法]
用using
如
using (IDataReader sdr = db.ExecuteReader(dbCommand))
{
if (sdr.Read())
{
uCorporationInfo = ReaderToModel(sdr);
}
}