Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
VB.NET
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBar.TextChanged
        ' Try
        Dim sql As String = "Select Barcode,ItemName,ItemDescription,Quantity,Price from Items"

        cnn.ConnectionString = "Provider=Microsoft.ACE.Oledb.12.0; Data Source=" & Application.StartupPath & "\InventSystem.accdb"
        cnn.Open()

        Dim dataadapter As New OleDbDataAdapter(sql, cnn)
        Dim ds As New DataSet()
        Dim dsView As New DataView
        Dim bs As New BindingSource()
        dataadapter.Fill(ds, "Items")
        cnn.Close()
        dsView = ds.Tables(0).DefaultView
        bs.DataSource = dsView
        bs.Filter = "Barcode LIKE '" & txtBar.Text & "*' or ItemName LIKE '" & txtBar.Text & "*' or ItemDescription '" & txtBar.Text & "*' or Quantity '" & txtBar.Text & "*'or Price '" & txtBar.Text & "*';"
        Me.DataGridView1.DataSource = bs
        cnn.Close()
        'Catch ex As Exception
        'MsgBox(ex.ToString, MsgBoxStyle.Critical)
        ' End Try
    End Sub


What I have tried:

im getting an error
JavaScript
Syntax error: Missing operand after ''2*'' operator.
Posted
Updated 20-Oct-16 23:56pm
v2

1 solution

You have forgotten to add compare operator like = or LIKE after Quantity and Price.
Change required in following code block-
VB
bs.Filter = "Barcode LIKE '" & txtBar.Text & "*' or ItemName LIKE '" & txtBar.Text & "*' or ItemDescription '" & txtBar.Text & "*' or Quantity '" & txtBar.Text & "*'or Price '" & txtBar.Text & "*';"


Hope, it helps :)
 
Share this answer
 
Comments
CaptainChizni 21-Oct-16 7:46am    
it works thank you
Suvendu Shekhar Giri 21-Oct-16 7:51am    
Glad to know that it helped :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900