I have a code for a messagebox to show when the user clicks on the submit button but it does not show. What did I do wrong? Is the code right?
protected void Submit_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HOTConnectionString"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("Insert into Table2013 (INST_ID, UNITID, ASTUDENTS, ACOMPLETED, ATRANSFERS, BSTUDENTS, BCOMPLETED, BTRANSFERS, YEAR, DATE) values (@INST_ID, @UNITID, @ASTUDENTS, @ACOMPLETED, @ATRANSFERS, @BSTUDENTS, @BCOMPLETED, @BTRANSFERS, @YEAR, @DATE)Insert into Table2014 (INST_ID, UNITID, ASTUDENTS, ACOMPLETED, ATRANSFERS, BSTUDENTS, BCOMPLETED, BTRANSFERS, YEAR, DATE) values (@INST_ID, @UNITID, @ASTUDENTS, @ACOMPLETED, @ATRANSFERS, @BSTUDENTS, @BCOMPLETED, @BTRANSFERS, @YEAR, @DATE)", con);
cmd.Parameters.AddWithValue("@ASTUDENTS", TextBoxTNUGSC.Text);
cmd.Parameters.AddWithValue("@ACOMPLETED", TextBoxTNUGSCD.Text);
cmd.Parameters.AddWithValue("@ATRANSFERS", TextBoxTTOUG.Text);
cmd.Parameters.AddWithValue("@BSTUDENTS", TextBoxTNGSC.Text);
cmd.Parameters.AddWithValue("@BCOMPLETED", TextBoxTNGSCD.Text);
cmd.Parameters.AddWithValue("@BTRANSFERS", TextBoxTTOG.Text);
cmd.Parameters.AddWithValue("@YEAR", TextBoxYEAR.Text);
cmd.Parameters.AddWithValue("@DATE", TextBoxDATE.Text);
cmd.Parameters.AddWithValue("@UNITID", TextBoxUNITID.Text);
cmd.Parameters.AddWithValue("@INST_ID", TextBoxINST_ID.Text);
try
{
cmd.ExecuteNonQuery();
con.Close();
Response.Redirect("Gradrate.aspx");
}
catch (Exception er)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('You Have Successfully Submitted Your Cohort')", true);
}
finally
{
}
}