0

the code doesnt retrieve any data from the database
datagridview1 always remains blank

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
        da.Fill(dt)
        dataGridView1.DataSource = dt
2
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by babbu
0

if i remove the single inverted commas this is the error that i get

Syntax error (missing operator) in query expression 'company like *?*'
0
..
oledbcom.CommandText = "Select * from customer where company like ?"
..
oledbcom.Parameters.Add("?", OleDb.OleDbType.VarChar)
Dim company As String = txtSearch.Text.Trim
oledbcom.Parameters(0).Value = "*" & company.ToString & "*"
...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.