public void crearIngrediente(Ingrediente ingrediente) { using (var conn = new SqlConnection(this.CONECCION_STRING)) { conn.Open(); // 1. create a command object identifying the stored procedure SqlCommand cmd = new SqlCommand("crearIngrediente", conn); // 2. set the command object so it knows to execute a stored procedure cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@nombreIngrediente", ingrediente.obtenerNombreIngrediente())); cmd.Parameters.Add(new SqlParameter("@precioIngrediente", ingrediente.obtenerValorIngrediente())); cmd.Parameters.Add(new SqlParameter("@cantidadDisponible", ingrediente.obtnerCantidaddisponible())); // execute the command using (SqlDataReader rdr = cmd.ExecuteReader()) { // iterate through results, printing each to console while (rdr.Read()) { Console.WriteLine("Product: {0,-35} Total: {1,2}", rdr["nombreIngrediente"], rdr["precioIngrediente"]); } } conn.Close(); } }