public void UpdateFoodBlog(int foodblogid, FoodBlog new_foodblog) { string query = "update foodblogpages set foodblogtitle='{0}', chefname='{1}', foodblogbody='{2}' where foodblogid={3}"; query = String.Format(query, new_foodblog.GetFoodBlogTitle(), new_foodblog.GetChefName(), new_foodblog.GetFoodBlogBody(), foodblogid); MySqlConnection Connect = new MySqlConnection(ConnectionString); MySqlCommand cmd = new MySqlCommand(query, Connect); try { //Try to update a food blog with the information provided to us. Connect.Open(); cmd.ExecuteNonQuery(); Debug.WriteLine("Executed query " + query); } catch (Exception ex) { Debug.WriteLine("Something went wrong in the UpdateFoodBlog Method!"); Debug.WriteLine(ex.ToString()); } Connect.Close(); }
protected void ShowFoodBlogInfo(FoodDriftersdb db) { bool valid = true; string foodblogid = Request.QueryString["foodblogid"]; if (String.IsNullOrEmpty(foodblogid)) { valid = false; } if (valid) { Debug.WriteLine("show the data"); FoodBlog foodblog_record = db.FindFoodBlog(Int32.Parse(foodblogid)); foodblogtitle.Text = foodblog_record.GetFoodBlogTitle(); chefname.Text = foodblog_record.GetChefName(); foodblogbody.Text = foodblog_record.GetFoodBlogBody(); } if (!valid) { ErrorBox.InnerHtml = "There was an error finding that foodblog."; } }
public void AddFoodBlog(FoodBlog new_recipe) { string query = "insert into foodblogpages (foodblogtitle, chefname, foodblogbody) values ('{0}','{1}','{2}')"; query = String.Format(query, new_recipe.GetFoodBlogTitle(), new_recipe.GetChefName(), new_recipe.GetFoodBlogBody()); MySqlConnection Connect = new MySqlConnection(ConnectionString); MySqlCommand cmd = new MySqlCommand(query, Connect); try { Connect.Open(); cmd.ExecuteNonQuery(); } catch (Exception ex) { Debug.WriteLine("Something went wrong in the AddFoodBlog Method!"); Debug.WriteLine(ex.ToString()); } Connect.Close(); }