Complementing the above information.
To execute a stored procedure you can do the following code:
using (var conn = new SqlConnection(connectionString))
{
try
{
SqlCommand command = new SqlCommand("[dbo].[nome_da_procedure]", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@PROC_PARAMETRO", SqlDbType.Int)).Value = 100;
command.Parameters.Add(new SqlParameter("@PROC_PARAMETRO1", SqlDbType.VarChar)).Value = 'valor';
conn.Open();
command.ExecuteNonQuery();
}
}
Some details regarding the procedure execution are: You can assign the result of a procedure to a variable:
var returnValue = command.ExecuteReader(); //Retorna a linha que foi executada
Taking the returned values:
string variavel = "";
while (returnValue.Read())
{
variavel = returnValue["COLUNA_TABELA"].ToString();
}