When I am performing update operation then the error
"An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code"
occured,how can I remove this?this error is occured on cmd.ExecuteNonQuery (line below the insert query)
protected void Button2_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection() ;
con.ConnectionString = @"Data Source=ADMIN\LOCALHOST;Initial Catalog=maha;Integrated Security=True;";
con.Open();
SqlCommand cmd = new SqlCommand("Insert into [dbo].[student]([ID],[NAME],[DOB],[GENDER]) Values ('" + TB1.Text + "','" + TB2.Text + "','" + TB3.Text + "','" + @rm + "')", con);
cmd.ExecuteNonQuery();
con.Close();
}
protected void Button3_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=ADMIN\LOCALHOST;Initial Catalog=maha;Integrated Security=True;";
con.Open();
SqlCommand cmd = new SqlCommand("Update [dbo].[student] set [ID]='" + TB1.Text + "',[NAME]='" + TB2.Text + "',[DOB]='" + TB3.Text + "',[GENDER]='" + @rm + "' where [ID]=='" + TB1.Text + "'", con);
cmd.ExecuteNonQuery();
con.Close();
}