title: How to insert values from a masked textbox to the database?
body: <p>I have used this code but showing me the error </p>
  
  <blockquote>
    <p>The input string was not in correct Format</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code> SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["String"].ConnectionString);
  
   try
   {
      con.Open();
  
      SqlCommand com = new SqlCommand("insert into TableYear where textBoxYear=" + int.Parse(maskedTextBox1.Text) + ";", con);
  
      SqlDataReader reader = com.ExecuteReader();
  
      int count = 0;
  
      while (reader.Read())
      {
          count++;
          string AY = reader.GetString(0);
          comboBoxAY.Items.Add(AY);
      }
      con.Close();
  }
  catch(Exception ex)
  {
      MessageBox.Show(ex.Message);
  }
  </code></pre>