title: Getting primary key after an insert in asp.net (visual basic)
body: <p>I'm adding a record like this:</p>
  
  <pre><code>    Dim pathString As String = HttpContext.Current.Request.MapPath("Banking.mdb")
      Dim odbconBanking As New OleDbConnection _
               ("Provider=Microsoft.Jet.OLEDB.4.0;" &amp; _
               "Data Source=" + pathString)
      Dim sql As String
      sql = "INSERT INTO tblUsers ( FirstName, LastName, Address, City, Province, Zip, Phone, UserName, [Password])" &amp; _
                " VALUES ('" &amp; firstName &amp; "', '" &amp; lastName &amp; "', '" &amp; address &amp; _
              "', '" &amp; city &amp; "', '" &amp; province &amp; "', '" &amp; zip &amp; "', '" &amp; phone &amp; "', '" &amp; username &amp; "', '" &amp; password &amp; "');"
      odbconBanking.Open()
      Dim cmd As New OleDbCommand(sql, odbconBanking)
      cmd.ExecuteNonQuery()
      odbconBanking.Close()
  </code></pre>
  
  <p>The primary key is an autonumber field called UserID. So, how do I get the primary key of the record I just inserted?</p>
  
  <p>Thanks.</p>