title: Vb.Net Windows Form Search Access Database
body: <p>Ok, hopefully I explain this correctly. I have had about 3 months professional experience working with Access databases, and none with Vb.net, but I am working on a project to get my degree. The goal of this project was to create a Windows Form for my parent's company, All Keyed Up Lock &amp; Safe. </p>
  
  <p>This form was going to link to an Access database with 4 tables that was a listing of some of the company's customers. The form would then allow you to search that database for a specific customer and then return all the information on that specific customer. </p>
  
  <p>This would be useful for billing and also would let us view any special notes we have on the customer before leaving. The four tables are <code>[McDonald's-Corporate Stores], [McDonald's-Independently Owned], [Sonic-Corporate Stores], [Sonic-Independently Owned]</code>. </p>
  
  <p>Basically the problem I am having is with the search function. I cannot for the life of me figure out a way to get this to work. I have tried 4 or 5 different solutions and still nothing. I am using Visual Studio 2013. Here is my code I have at the moment, for the search button:</p>
  
  <pre><code>  Private Sub SearchButton_Click(sender As Object, e As EventArgs) Handles SearchButton.Click
          Dim Connection As New SqlClient.SqlConnectionStringBuilder
          Connection.DataSource = "file:///C:\Users\thelukester145\Documents\All%20Keyed%20Up\All%20Keyed%20Up,%20Lock%20&amp;%20Safe,%20LLC.accdb"
          Dim objSQLConnection = New SqlClient.SqlConnection(Connection.ConnectionString)
          Dim cmd As New SqlCommand()
          Dim myTable As New DataTable()
          Dim SearchFor = SearchBox.Text
          If AddressButton.Checked Then
              cmd.Connection = objSQLConnection
              cmd.CommandText = "SELECT * FROM [McDonald's-Corporate Stores] WHERE [Address] LIKE '%" &amp; SearchFor &amp; "%'"
              Dim myAdapter As New SqlDataAdapter(cmd)
              myAdapter.Fill(myTable)
              DataGrid.DataGridView1.DataSource = myTable
          ElseIf NumberButton.Checked Then
              cmd.Connection = objSQLConnection
              cmd.CommandText = "SELECT * FROM [McDonald's-Corporate Stores] WHERE [McOpCo#] LIKE '%" &amp; SearchFor &amp; "%'"
              Dim myAdapter As New SqlDataAdapter(cmd)
              myAdapter.Fill(myTable)
              DataGrid.DataGridView1.DataSource = myTable
          End If
          DataGrid.Show()
  
  
      End Sub
  </code></pre>
  
  <p>As you can see I have just been trying to get this to work for just one table and can't even do that. I would prefer not to use the datagrid method to display the information but rather display it in textboxes that are positioned on the form. </p>
  
  <p>Anyways any help would be MUCH appreciated and sorry for such a long question.</p>