在程序中如何得到存储过程反回值 在asp.net中如何得到存储过程反回值. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 add ParameterDirection.ReturnValue type parameter, if you are using DataReader, you need to close it first, seehttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconusingstoredprocedureswithcommand.aspSqlCommand sampleCMD = new SqlCommand("SampleProc", nwindConn);sampleCMD.CommandType = CommandType.StoredProcedure;SqlParameter sampParm = sampleCMD.Parameters.Add("RETURN_VALUE", SqlDbType.Int);sampParm.Direction = ParameterDirection.ReturnValue;sampParm = sampleCMD.Parameters.Add("@InputParm", SqlDbType.NVarChar, 12);sampParm.Value = "Sample Value";sampParm = sampleCMD.Parameters.Add("@OutputParm", SqlDbType.NVarChar, 28);sampParm.Direction = ParameterDirection.Output;nwindConn.Open();SqlDataReader sampReader = sampleCMD.ExecuteReader();Console.WriteLine("{0}, {1}", sampReader.GetName(0), sampReader.GetName(1));while (sampReader.Read()){ Console.WriteLine("{0}, {1}", sampReader.GetInt32(0), sampReader.GetString(1));}sampReader.Close();nwindConn.Close();Console.WriteLine(" @OutputParm: {0}", sampleCMD.Parameters["@OutputParm"].Value);Console.WriteLine("RETURN_VALUE: {0}", sampleCMD.Parameters["RETURN_VALUE"].Value); command.Parameters.Add("@abc", SqlDbType.VarChar, 200);command.Parameters("@abc").Direction = ParameterDirection.Output;...connection.Open();command.ExecuteNonQuery();connection.Close();...string abc = command.Parameters("@abc").Value.ToString(); Javascript 给Panel下所有Div加样式 页面的meta标签的description动态生成的影响 菜鸟问题 :关于Dropdownlist的简单问题??? =====验证域名是否标准的正则表达式? 关于DataGrid分页的怪问题 IIS错误,我不太明白,请帮忙看看 求控件,100分够吧 login2.0 控件强制第一次登陆问题 急急急急!!!关于表单提交与直接在浏览器中键入地址的问题 请教:怎么样在页面中调用cs文件中的函数? 请问要学好Asp.Net胧共分几步,请过来人指路 在ASP.Net开发中,我想自己写程序解析 <httpHandlers>元素,可以实现吗?如何实现?
sampleCMD.CommandType = CommandType.StoredProcedure;SqlParameter sampParm = sampleCMD.Parameters.Add("RETURN_VALUE", SqlDbType.Int);
sampParm.Direction = ParameterDirection.ReturnValue;sampParm = sampleCMD.Parameters.Add("@InputParm", SqlDbType.NVarChar, 12);
sampParm.Value = "Sample Value";sampParm = sampleCMD.Parameters.Add("@OutputParm", SqlDbType.NVarChar, 28);
sampParm.Direction = ParameterDirection.Output;nwindConn.Open();SqlDataReader sampReader = sampleCMD.ExecuteReader();Console.WriteLine("{0}, {1}", sampReader.GetName(0), sampReader.GetName(1));while (sampReader.Read())
{
Console.WriteLine("{0}, {1}", sampReader.GetInt32(0), sampReader.GetString(1));
}sampReader.Close();
nwindConn.Close();Console.WriteLine(" @OutputParm: {0}", sampleCMD.Parameters["@OutputParm"].Value);
Console.WriteLine("RETURN_VALUE: {0}", sampleCMD.Parameters["RETURN_VALUE"].Value);
command.Parameters("@abc").Direction = ParameterDirection.Output;...connection.Open();
command.ExecuteNonQuery();
connection.Close();...string abc = command.Parameters("@abc").Value.ToString();