Hi first of all , it's not safety to insert a value to SQL via text.
It would be better to use
SqlParameter class instead, to put values to DB.
try
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["WindowsFormsApplication1.Properties.Settings.schoolConnectionString"].ConnectionString);
con.Open();
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandText = "insert into Registration(Name,Id) values(@p1,@p2 ...);
var p1=new SqlParameter("@p1", SqlDbType.VarChar);
p1.Value="Hello";
com.Parameters.Add(p1);
var p2=new SqlParameter("@p2", SqlDbType.Int);
p2.Value=78;
com.Parameters.Add(p2);
com.ExecuteNonQuery();
MessageBox.Show("Record is saved");
autoNo();
maskedTextBox2.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
textBox6.Clear();
textBox7.Clear();
maskedTextBox3.Clear();
textBox8.Clear();
textBox10.Clear();
}
catch
{
MessageBox.Show("error:");
}