using (SqlConnection con = new SqlConnection(strConnect))
{
con.Open();
using (SqlCommand com = new SqlCommand("MyStoredProcedureName", con))
{
com.CommandType = CommandType.StoredProcedure;
SqlParameter name = new SqlParameter("@Name", SqlDbType.VarChar, 100);
name.Direction = ParameterDirection.Output;
com.Parameters.Add(name);
com.Parameters.AddWithValue("@SearchForID", 12345);
com.ExecuteNonQuery();
string r = (string) name.Value;
string s = (string) com.Parameters["@Name"].Value;
}
con.Close();
}
Calls an SP which takes an ID value as a parameter, and returns the username as another parameter.