title: Search / Query an access database from textbox in vb wthout datagrid view
body: <p>Hey guys I need a little assistance in doing a basic search query from my form program to connect to an access database. basically I want to learn how to with the click of my query button, search text entered in a textbox  and show the corresponding data in another text box, based on a match found. Any help would be greatly appreciated.</p>
  
  <p>here is the code of my query button so far..</p>
  
  <pre><code>Private Sub btnQuery_Click(sender As Object, e As EventArgs) Handles btnQuery.Click
  
      con = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Eric\Documents\Fadv.accdb")
  
      con.Open()
  
  
      Dim id As Integer
      Dim SQL As String = "SELECT FirstName, NAME FROM info WHERE FirstName=" &amp; txtFirstName.Text &amp; ""
  
      Using cmd As New OleDbCommand(SQL, con)
  
          id = Val(InputBox("Enter Query Criteria"))
  
          MsgBox(SQL)
          cmd.ExecuteNonQuery()
  
          con.Close()
  </code></pre>
  
  <h2>        End Using</h2>
  
  <p>Im having a little trouble trying to figure out the (connectionstring) Im not sure if this is something I have to declare so far here is that my code, any guidance would be greatly appreciated.</p>
  
  <p>` Private Sub btnQuery_Click(sender As Object, e As EventArgs) Handles btnQuery.Click</p>
  
  <pre><code>    Using con As New OleDbCommand(connectionstring)
  
          Dim cmd As New OleDbCommand(SQL, con)
  
          con.open()
  
          Dim reader As OleDbDataReader = cmd.ExecuteReader()
  
          While reader.Read()
  
              txtFirstName.Text = reader(0).ToString())
  
          End While
  
          reader.Close()
  
      End Using
  </code></pre>
  
  <p>`</p>