title: Fill DataGridView with data from SQL
body: <p>I want to fill a DataGridView with data returned from a SQL.  So here is my code <em>[I provided cause some people may think I'm asking for help before trying myself]</em></p>
  <p>I want the DataGridView to be filled by a data from SQL not to show all the records.</p>
  <p>The SQL <strong>&quot;Select * From books where title='php%' Order By Title;&quot;</strong></p>
  <h1>useless code :(   :'(   :&lt;</h1>
  <pre><code>Imports System.Data
  Imports System.Data.SqlClient
  Public Class frmMain
   Dim connectionString = &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Database.mdb;Persist&quot; &amp; &quot; Security Info=True&quot;
  
   Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.BooksTableAdapter.Fill(Me.TblBooks.books)
   End Sub
  
    Private Sub txtTerm_TextChanged() Handles txtTerm.TextChanged
     If Trim(txtTerm.Text) = &quot;&quot; Then Exit Sub
  
     Dim tblCustomBooks As New DataTable
     Dim adpBooks As New OleDb.OleDbDataAdapter(&quot;Select * From books where title='php%' Order By Title&quot;, _
    '&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Database.mdb;Persist&quot; &amp; &quot; Security Info=True&quot;)
     adpBooks.Fill(tblCustomBooks)
     BooksTableAdapter.Fill(tblCustomBooks)
    'Dim myConnection As SqlConnection
    'Dim myCommand As SqlDataAdapter
    'myConnection = New SqlConnection(&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Database.mdb;Persist&quot; &amp; &quot; Security Info=True&quot;)
    'myCommand = New SqlDataAdapter(&quot;Select * From books where title='php%' Order By Title&quot;, myConnection)
    'Dim ds As DataSet = New DataSet()
    'myCommand.Fill(ds)
    'gridTable.DataSource = ds
   End Sub
  </code></pre>