title: How to get the auto increment primary key in old mdb database?
body: <p>I have to retrieve the Auto_Increment primary key (id) after inserting a new row in a mdb access database.
  Having mdb file in the old Access 97 version too, I cannot use "SELECT @@Identity;", because it is not supported.</p>
  
  <p>Besides, in a multi users environment I do not like the idea to use Max(ID).</p>
  
  <p>Actually the only solution I have, it is to use the DAO as:</p>
  
  <pre><code>Dim db As Database          'Test Database
  Dim rs As Recordset         'Test Table
  ...
  rs.AddNew
  id = rs!id
  </code></pre>
  
  <p>but I have to add a reference to the DAO COM DLL, while I would like to have a full managed .NET code.</p>
  
  <p>Do you have any suggestion how to retrieve the Auto_Increment primary key (after inserting a new row) without using DAO or Max(ID)?</p>
  
  <p>Here my code to add a new row:</p>
  
  <pre><code>    Using oConn As New OleDbConnection(m_ConnString)
          oConn.Open()
          Using cmd As New OleDbCommand(sqlInsert, oConn)
              cmd.ExecuteNonQuery()
          End Using
      End Using
  </code></pre>
  
  <p>Thank you.</p>