title: Getting last autonumber in access
body: <p>I am trying to get last auto number after inserting record into access database. I am getting zero. Not sure what I am doing wrong. I tried to google but could not find any simple example which I can use to understand.</p>
  
  <pre><code>// Database was opened before.
  cmd.ExecuteNonQuery(); // Insert is working fine.
  cmd = new OleDbCommand("SELECT @@IDENTITY", con);
  id = cmd.ExecuteNonQuery(); // id shows zero in debug
  </code></pre>