protected void ShowBlogPostInfo(BLOGDB db) { bool valid = true; string blogid = Request.QueryString["blogid"]; if (String.IsNullOrEmpty(blogid)) { valid = false; } if (valid) { BLOGPOST blogpost_record = db.FindBlogPost(Int32.Parse(blogid)); blogpost_title_head.InnerHtml = blogpost_record.GetBPTitle(); blogpost_title.InnerHtml = blogpost_record.GetBPTitle(); blogpost_body.InnerHtml = blogpost_record.GetBPBody(); } else { valid = false; } if (!valid) { blog.InnerHtml = "There was an error finding that blog post"; } }
public void UpdateBlogPost(int blogid, BLOGPOST new_post) { //am i getting here? Debug.WriteLine("is this where the problem is?"); string query = "update blog_post set blogtitle='{0}', blogbody='{1}' where blogid={2} "; query = String.Format(query, new_post.GetBPTitle(), new_post.GetBPBody(), blogid); Debug.WriteLine("am i getting the information i need?"); MySqlConnection Connect = new MySqlConnection(ConnectionString); MySqlCommand cmd = new MySqlCommand(query, Connect); try { Connect.Open(); cmd.ExecuteNonQuery(); Debug.WriteLine("Execute query" + query); } catch (Exception ex) { Debug.WriteLine("Something went wrong in the UpdateBlog Method!"); Debug.WriteLine(ex.ToString()); } Connect.Close(); }
protected void ShowBlogInfo(BLOGDB db) { bool valid = true; string blogid = Request.QueryString["blogid"]; if (String.IsNullOrEmpty(blogid)) { valid = false; } if (valid) { Debug.WriteLine("is this it?"); BLOGPOST blog_record = db.FindBlogPost(Int32.Parse(blogid)); update_title.InnerHtml = blog_record.GetBPTitle(); blog_title.Text = blog_record.GetBPTitle(); blog_post.Text = blog_record.GetBPBody(); } if (!valid) { blog.InnerHtml = "There was an error updating your blog"; } }
public void AddBlogPost(BLOGPOST new_post) { string query = 'insert into blog_post (blogtitle, blogbody) values ("{0}","{1}")'; query = String.Format(query, new_post.GetBPTitle(), new_post.GetBPBody()); MySqlConnection Connect = new MySqlConnection(ConnectionString); MySqlCommand cmd = new MySqlCommand(query, Connect); try { Connect.Open(); cmd.ExecuteNonQuery(); } catch (Exception ex) { Debug.WriteLine("Something went wrrong in the AddPost Method!"); Debug.WriteLine(ex.ToString()); } Connect.Close(); }