using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Web.UI;


public partial class Soma : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ConnectionStringSettings getString = WebConfigurationManager.ConnectionStrings["nwind"] as ConnectionStringSettings;
            if (getString != null)
            {
                using (SqlConnection conn = new SqlConnection(getString.ConnectionString))
                {
                    SqlCommand cmd = new SqlCommand("Contar", conn);
                    cmd.CommandType = CommandType.StoredProcedure;

                    SqlParameter param;
                    param = cmd.Parameters.Add(new SqlParameter("@soma1", SqlDbType.Int));
                    param.Direction = ParameterDirection.Input;
                    param.Value = 1;

                    param = cmd.Parameters.Add(new SqlParameter("@soma2", SqlDbType.Int));
                    param.Direction = ParameterDirection.Input;
                    param.Value = 3;

                    param = cmd.Parameters.Add(new SqlParameter("@total", SqlDbType.Int));
                    param.Direction = ParameterDirection.Output;
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    Response.Write("Soma total: " + cmd.Parameters["@total"].Value);
                }
            }
        }
    }
}