protected void Button1_Click(object sender, EventArgs e) { Forumfeedback sob = new Forumfeedback(TextBox1.Text, TextBox3.Text, TextBox2.Text, txtpostmessage.InnerText.ToString(), txtposttitle.Text); Class1 dbcon = new Class1(); dbcon.Fouremmessage(sob); Response.Write("<script LANGUAGE='JavaScript' >alert('Save Successful')</script>"); TextBox1.Text = string.Empty; TextBox2.Text = string.Empty; TextBox3.Text = string.Empty; txtpostmessage.InnerText.ToString(); txtposttitle.Text = string.Empty; }
public void Fouremmessage(Forumfeedback ob) { try { mcon.Open(); string sqlQ = "insert into Forum(Title,Date,email,Message,UserName) values ('" + ob.title + "','" + ob.date + "','" + ob.email + "','" + ob.message + "','" + ob.userName + "')"; SqlCommand cmd = new SqlCommand(sqlQ, mcon); cmd.ExecuteNonQuery(); } catch (Exception ex) { } finally { mcon.Close(); } }