i have a datagrid view. i am using data table to display data

        m_daDataAdapter = New OleDb.OleDbDataAdapter("Select * from Customer", oledbcon)
        m_cbCommandBuilder = New OleDb.OleDbCommandBuilder(m_daDataAdapter)
        m_rowPosition = m_dtCustomer.Rows.Count
        dataGridView1.DataSource = m_dtCustomer

this works great.

later i want to display only those records tht the user types in the text box. so i use this code

Dim oledbcom As New OleDb.OleDbCommand
        oledbcom.CommandText = "Select * from Customer where Company like ?"
        oledbcom.Connection = oledbcon


        oledbcom.Parameters.Add("?", OleDb.OleDbType.VarChar)
        Dim company As String = txtSearch.Text.Trim
        oledbcom.Parameters(0).Value = "*" & company.ToString & "*"

        Dim da As New OleDb.OleDbDataAdapter(oledbcom)
        Dim dt As New DataTable
        dataGridView1.DataSource = dt

no data is displayed when this code is executed in the text changed event
m using access 2007.


i tried this but it did not work
is there any other error

intellisense doesnt show any option related to databind
dt.databind doesnt exist

i tried using data reader and figured out one thing
its not executing the like query instead it looks for the folllowing pattern
* + contents in the text box + *
its looking for the exact match including the asteriks

how do i use the like operator along with the wild card
plz help

try this
'%" + field.Text .toString()+ "%'
'%" + field.Text + "%'

This question has already been answered. Start a new discussion instead.