title: How to INSERT INTO access database with c#
body: <p>I am trying to add data to my access database from winform using c#.</p>
  
  <p>I keep getting a syntax error regarding my INSERT INTO statement and cannot see where I am going wrong.</p>
  
  <p>Please can someone review my code and tell me where I am going wrong.</p>
  
  <pre><code>private void btnLog_Click(object sender, EventArgs e)
  {
      txtStatus.Text = "Open";
  
      conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\mwool\\Desktop\\Uni\\3rd Year\\SEM 1\\AP\\Assignment\\Staff.accdb";
  
      string sql = "INSERT INTO Fault (faultType, Status, TechId, StaffId, Zone, Description) VALUES ('" + txtFaultType.Text + "', '" + txtStatus.Text + "', " + txtTechId.Text + "' , '" + txtStaffId.Text + "' , '" + txtZone.Text + "' , '" + txtDescription.Text + "')";
  
      OleDbCommand add = new OleDbCommand();
  
      add.CommandText = sql;
  
      add.Connection = conn;
  
      add.Connection.Open();
  
      add.ExecuteNonQuery();
  
      conn.Close();
  
  }
  </code></pre>