title: Deleting primary key from database
body: <p>In my database I have two tables, <code>Orders</code> and <code>Items</code>. If I insert two orders with ID 1 and 2 and then delete the second one then my next ID will be 3. This I understand, I'm also aware that I shouldn't interfere with primary keys in my tables. But what's bugging me if there really isn't some way to shrink ID so when I delete ID 2 then next time when I add some order to my database I will like for it to be placed on ID 2. Autonumber then falls of or?</p>
  
  <p>I've probably done it the wrong way because I'm getting my order in this function:</p>
  
  <pre><code> Private Sub GetLastOrderID()
      Try
          sqL = "SELECT ID FROM Order ORDER BY ID Desc"
          ConnDB()
          cmd = New OleDbCommand(sqL, conn)
          dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
  
          'next id in database is current + 1
          If dr.Read = True Then
              txtOrderID.Text = dr("ID") + 1
          Else
              txtidnarocila.Text = 1
          End If
      Catch ex As Exception
          MsgBox(ex.Message)
      Finally
          cmd.Dispose()
          conn.Close()
      End Try
  End Sub
  </code></pre>
  
  <p>So in general I have problem when I delete Order on some ID then program does not know that there is missing ID. When I delete ID 2, my code still sees only one ID in database and again I have "next id" as 2. But In database is 3.</p>
  
  <p>Asking for some instructions. Thank you.</p>