//C# SP Call
public static void GetOutputVals()
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["dbConnection"].ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "GetOutputVals";
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@code", SqlDbType.NVarChar,50).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@price", SqlDbType.Decimal,14).Direction = ParameterDirection.Output;
string a;
decimal b;
try
{
con.Open();
cmd.ExecuteNonQuery();
a = (string)cmd.Parameters["@code"].Value;
b = (decimal)cmd.Parameters["@price"].Value;
}
catch (SqlException err)
{
throw new ApplicationException("Data error." + err);
}
finally
{
con.Close();
con.Dispose();
}
}
//Store Proc
CREATE proc GetOutputVals
@code nvarchar(50) output,
@price decimal(12,2) output
as
begin
set @code='111'
set @price=3333
select @code, @price
end