dotnetsr

Dear all,

I'm using following code to filter data in listbox. But error msg Syntax Error: Missing Operand after 'ProductName' Operator appears. Can any one figure out the Syntax error please.

Private Sub FilterProductId()

Try

Dim ProductIDs As TechManagement.DBComponents.ProductDB = New TechManagement.DBComponents.ProductDB

Dim filterview As DataView = New DataView(ProductIDs.GetProductIDS)

filterview.RowFilter = "ProductID Like '" & txtProductID.Text & "%'" & "ProductName Like '" & txtProductID.Text & "%'"

lstProducts.DataSource = filterview

Catch ex As Exception

MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

End Try

End Sub

Thanks



Re: Visual Basic General Rowfilter error in DataView (Syntax Error: Missing Operand after 'ProductName' Operator

cybertaz69

Havn't used dataview for a long time but here is my shoot....

filterview.RowFilter = "ProductID Like '" & txtProductID.Text & "%'" & "ProductName Like '" & txtProductID.Text & "%'"
no space no operator ' and' ' or' etc

filterview.RowFilter = "ProductID Like '" & txtProductID.Text & "% or '" & "ProductName Like '" & txtProductID.Text & "%'"






Re: Visual Basic General Rowfilter error in DataView (Syntax Error: Missing Operand after 'ProductName' Operator

dotnetsr

cybertaz69 Thanks for your reply.

But it does not work. I changed the code as below after filtering, it gives strange data in the listbox "System.Data.DataRowView"

Here something Error I can' short out.

filterview.RowFilter = "ProductID LIKE '%" & txtProductID.Text & "' OR ProductName LIKE '%" & txtProductID.Text & "%'"

So any one can helpme pls....

Thanks





Re: Visual Basic General Rowfilter error in DataView (Syntax Error: Missing Operand after 'ProductName' Operator

cybertaz69

Please explain what you mean by strange data




Re: Visual Basic General Rowfilter error in DataView (Syntax Error: Missing Operand after 'ProductName' Operator

dotnetsr

"System.Data.DataRowView"



Re: Visual Basic General Rowfilter error in DataView (Syntax Error: Missing Operand after 'ProductName' Operator

cybertaz69

set the member

lstProducts.displaymember = "MyColumnName"






Re: Visual Basic General Rowfilter error in DataView (Syntax Error: Missing Operand after 'ProductName' Operator

dotnetsr

Thank you verymuch cybertaz69

But I have 2 columns. I know it is impossible to put 2 columns as DisplayMember. So what is the solution

Thanks for giving your valuable time





Re: Visual Basic General Rowfilter error in DataView (Syntax Error: Missing Operand after 'ProductName' Operator

cybertaz69

No the list box can only show one column using the current technique.. Its possable if you load the data manully but i suggest to use a DataGridView.

The DGV can look just like a list if you strip off the extras and still have more than one column.