ADO.Net检索sp的输出 [英] ADO.Net retreiving output from sp

查看:58
本文介绍了ADO.Net检索sp的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SqlConnection con = new SqlConnection(connection);
SqlCommand com = new SqlCommand("Login_Validation",con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@username", txtBoxUserName)



我写了一个Sp,它接受用户名作为输入,并通过输出参数返回passowrd.现在如何在上面的代码中获取该值...?



i wrote a Sp which takes username as input and returns the passowrd as out put throught output parameter..now how can i get that value in the above code...?

推荐答案

<code>using (SqlDataReader reader = com.ExecuteReader(CommandBehavior.CloseConnection))
{
if (reader.HasRows && reader.Read())
{
String thePassword = reader[0].ToString();
}
reader.Close();
}</code>


这篇关于ADO.Net检索sp的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆