title: Microsoft Access UPDATE command using C# OleDbConnection and Command NOT working
body: <p>I'm using Microsoft Access unfortunately because of higher forces and trying to update a record with no luck.</p>
  
  <p>This is the code:</p>
  
  <pre><code>private void UpdateContact(Contact contact)
  {
      using (OleDbConnection db = new OleDbConnection(_connString))
      {
          string query = "UPDATE [Contact] SET [FirstName] = @FirstName, [LastName] = @LastName, [MobileNumber] = @MobileNumber WHERE [Id] = @Id";
  
          OleDbCommand cmd = new OleDbCommand(query, db) { CommandType = CommandType.Text };
          cmd.Parameters.AddWithValue("@Id", contact.Id);
          cmd.Parameters.AddWithValue("@FirstName", contact.FirstName);
          cmd.Parameters.AddWithValue("@LastName", contact.LastName);
          cmd.Parameters.AddWithValue("@MobileNumber", contact.MobileNumber);
  
          db.Open();
  
          int rowsAffected = cmd.ExecuteNonQuery();
  
          db.Close();
      }
  }
  </code></pre>
  
  <p>Everything seems to be fine, no exception but no rowsAffected either. It always returns 0.
  I have checked the values while debugging and its the correct that should persist.
  The access file created with MS Access 2007 but its type is of 2002-2003.</p>
  
  <p>Any idea what am I doing wrong?</p>