protected void AddPost(object sender, EventArgs e) { BLOGDB db = new BLOGDB(); BLOGPOST new_post = new BLOGPOST(); new_post.SetPTitle(page_title.Text); new_post.SetPBody(page_body.Text); db.Add_Post(new_post); Response.Redirect("blogarchive.aspx"); }
public void Add_Post(BLOGPOST new_post) { string query = "insert into blog_page (pagetitle, pagebody) values ('{0}','{1}')"; query = String.Format(query, new_post.GetPTitle(), new_post.GetPBody()); 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(); }