private void btnSave_Click_1(object sender, EventArgs e)
{
conn = new SqlConnection(connstr);
comm = new SqlCommand();
conn.Open();
SqlParameter code = new SqlParameter("@code", SqlDbType.NChar);
comm.Parameters.Add(code);
code.Value = mycode.Text;
comm.Connection = conn;
comm.CommandText = "insert into classenumer values(@code)";
try
comm.ExecuteNonQuery();
MessageBox.Show("Good saving!");
mycode.Clear();
}
catch (Exception)
MessageBox.Show("Sorry, not saved");
finally
conn.Close();