public void UpdateAmount(Ingredient targetIngredient, string newAmount) { SqlConnection conn = DB.Connection(); conn.Open(); SqlCommand cmd = new SqlCommand("UPDATE recipes_ingredients SET amount = @NewAmount WHERE recipe_id = @TargetId AND ingredient_id= @TargetIngredientId; ", conn); cmd.Parameters.Add(new SqlParameter("@NewAmount", newAmount)); cmd.Parameters.Add(new SqlParameter("@TargetId", this.GetId())); cmd.Parameters.Add(new SqlParameter("@TargetIngredientId", targetIngredient.GetId())); cmd.ExecuteNonQuery(); targetIngredient.SetAmount(newAmount); DB.CloseSqlConnection(conn); }