Supplementing the above information.
To run a stored trial you can do according to the code below:
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 execution of the precedent are: You can assign the result of a precedent 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();
}
I suggest changing the title,
procedure
is a very generic word. However, I don’t know what to exchange.– fotanus
@fotanus What do you mean? Proceed is part of :S syntax
– Luiz Negrini
The ideal would be Stored Procedure, commonly called SP.
– E.Thomas