public void ShowPageInfo(Dbconnection db) { bool valid = true; string pageid = Request.QueryString["pageid"]; if (String.IsNullOrEmpty(pageid)) { valid = false; } if (valid) { //finding the page we requested by refering the function FindHttpPage in Dbconnection.cs and gets the records to display on html page HttpPage page_record = db.FindHttpPage(Int32.Parse(pageid)); heading.InnerHtml = page_record.GetPageTitle(); pagecontent.InnerHtml = page_record.GetPageContent(); author.InnerHtml = "Author:" + " " + page_record.GetPageAuthor(); Publishdate.InnerHtml = "Published on" + " " + page_record.GetPagePublish_Date(); } else { valid = false; } }
//Add New Page to database public void AddPage(HttpPage new_HttpPage) { string query = "insert into pages (pagetitle, pagebody, author, Publish_Date) values ('{0}','{1}','{2}','{3}')"; query = String.Format(query, new_HttpPage.GetPageTitle(), new_HttpPage.GetPageContent(), new_HttpPage.GetPageAuthor(), new_HttpPage.GetPagePublish_Date()); 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 Addpage Method!"); Debug.WriteLine(ex.ToString()); } Connect.Close(); }