title: Access Database VB - Searching a database for most 'RECENT' record
body: <p>I was wondering how I could change the code below, to allow me to search for the most recent record. I am creating a Hotel Booking System and want to use the most recent price in the database but at the moment, it is just searching using the labels which I don't want.</p>
  
  <pre><code>Dim str1 As String
  Dim dbpassword As String = "123"
  Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source= E:\Computing\Hotel Booking System\Database\Hotel Booking System.accdb ;Jet OLEDB:Database Password =" &amp; dbpassword &amp; ";"
  Dim MyConn As OleDbConnection
  Dim dr As OleDbDataReader
  
  Private Sub Information_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  
      Dim PriceFound As String = False
      MyConn = New OleDbConnection
  
      MyConn.ConnectionString = connString
  
      MyConn.Open()
  
      str1 = ("SELECT * FROM [Prices] WHERE [Adult] = '" &amp; LblPriceAdult.Text &amp; "' AND [Child] = '" &amp; LblPriceChild.Text &amp; "'")
  
      Dim cmd1 As OleDbCommand = New OleDbCommand(str1, MyConn)
  
      dr = cmd1.ExecuteReader
  
      While dr.Read()
  
  
          PriceFound = True
          DateDisplay = dr("ID").ToString
          AdultPrice = dr("Adult").ToString
          ChildPrice = dr("Child").ToString
          SingleRoom = dr("Single").ToString
          DoubleRoom = dr("Double").ToString
          FamilyRoom = dr("Family").ToString
  
          If PriceFound = True Then
              LblPriceAdult.Text = AdultPrice
              LblPriceChild.Text = ChildPrice
              LblPriceDoubleRoom.Text = DoubleRoom
              LblPriceFamilyRoom.Text = FamilyRoom
              LblPriceSingleRoom.Text = SingleRoom
          End If
      End While
      MyConn.Close()
  End Sub
  </code></pre>