Click here to Skip to main content
15,913,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SqlConnection con = new SqlConnection(connection);
SqlCommand com = new SqlCommand("Login_Validation",con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@username", txtBoxUserName)


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...?
Posted
Updated 19-Jul-11 22:24pm
v2

1 solution

<code>using (SqlDataReader reader = com.ExecuteReader(CommandBehavior.CloseConnection))
{
if (reader.HasRows && reader.Read())
{
String thePassword = reader[0].ToString();
}
reader.Close();
}</code>
 
Share this answer
 
Comments
AnirudhKalva 20-Jul-11 4:37am    
i ma not able to retrieve the password as output
Ankur\m/ 20-Jul-11 4:52am    
Since there is only one value that is returned, using CommandObject.ExecuteScalar() method more suits here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900