Jyoti Jodha

Jyoti Jodha

  • NA
  • 1.7k
  • 406.9k

buttons don't work in asp.net c#

Oct 4 2017 7:29 AM
I am Using bootstrap templates
and i am want to save data in data base
don't show any Error or don't save data in database 
 
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con;
con = new SqlConnection(ConfigurationManager.AppSettings["connect"]);
con.Open();
SqlCommand cmd;
cmd = new SqlCommand("Insert into registration (name,class) values('" + TextBox1.Text + "','" + TextBox2.Text + "')", con);
try
{
con.Open();
cmd.ExecuteNonQuery();
Label14.Text = "Data inserted successfully";
con.Close();
refress();
}
catch (Exception ex)
{
Label14.Text = ex.Message;
}
}
 

Answers (8)