I have a stored procedure with 6 input parameter and 4 output parameter. In My asp.net – C# code I execute the stored procedure and return the parameter.The stored Procedure execute but the return value is empty. (when I try execute in sql it return data). This is my code.
connection.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
using (SqlConnection connection = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]))
{
SqlCommand cmd = new SqlCommand("w_create_order", connection);
cmd.CommandType =
CommandType.StoredProcedure;
//input parameters
cmd.Parameters.AddWithValue(
"@in_order_class", "WEB");
cmd.Parameters.AddWithValue(
"@in_owner_code", "OP");
cmd.Parameters.AddWithValue(
"@in_sales_campaign_code", "DEF");
cmd.Parameters.AddWithValue(
"@in_cus_key", null);
cmd.Parameters.AddWithValue(
"@in_lab_key", null);
cmd.Parameters.AddWithValue(
"@in_invoice_number", null);
connection.Open();
cmd.ExecuteNonQuery();
//output parameters
//output parameters
cmd.Parameters.Add(
"@ord_key", SqlDbType.Int, 500);
cmd.Parameters[
"@ord_key"].Direction = ParameterDirection.Output;
cmd.Parameters.Add(
"@ord_invoice_number", SqlDbType.Int, 500);
cmd.Parameters[
"@ord_invoice_number"].Direction = ParameterDirection.Output;
cmd.Parameters.Add(
"@via_ship_via_code", SqlDbType.NVarChar, 500);
cmd.Parameters[
"@via_ship_via_code"].Direction = ParameterDirection.Output;
string message = (string)cmd.Parameters["@via_ship_via_code"].Value;
cmd.Parameters.Add(
"@ord_ship_after_date", SqlDbType.DateTime);
cmd.Parameters[
"@ord_ship_after_date"].Direction = ParameterDirection.Output;
Label1.Text = message;
connection.Close();
}
}