title: Why can I not insert numerical values into a MS Access Database through an sql query in c# windows form?
body: <p>I used the following code to insert data into a database</p>
  <pre><code>public partial class Products : Form
  {
      private OleDbConnection connection = new OleDbConnection();
      public Products()
      {
          InitializeComponent();
          connection.ConnectionString = @&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Folder\Database.mdb;Persist Security Info=False;&quot;;
      }
  private void cmdAdd_Click(object sender, EventArgs e)
      {
          try
          {
              connection.Open();
              OleDbCommand command = new OleDbCommand();
              command.Connection = connection;
              command.CommandText = &quot;INSERT INTO Products (ProductName, Quantity, Weight(g)) VALUES ('&quot; + txtName.Text + &quot;', '&quot; + txtQuantity.Text + &quot;', '&quot; + txtWeight.Text + &quot;')&quot;;
              
              command.ExecuteNonQuery();
              MessageBox.Show(&quot;Data saved&quot;);
              connection.Close();
          }
          catch (Exception ex)
          {
              MessageBox.Show(&quot;Error&quot; + ex);
          }
          
  
      }
  </code></pre>
  <p>And the last two variables don't seem to work. I tried entering a string for the first field and it works perfectly, but when I go to insert a number on the last two variables it throws an exception. I've already tried doing int.Parse(txtQuantity.Text) but it doesn't work either.</p>