Search code examples
databasevb.netfilterlong-integerbindingsource

VB.NET BindingSource Filter two column conversion not valid


I need to filter my Table2 with ID number and with year >=2010.

This is my code for filter:

Me.Table2BindingSource.Filter = "osobljeID ='" & OsobljeIDTextBox.Text & "'" And "Godina >=" & txtGodP.Text

When I start app and click on button with this code I got:

Conversion from string "osobljeID ='1'" to type 'Long' is not valid.

When I use only one column to filter all is working but I need two.

(e.g [Me.Table2BindingSource.Filter = "osobljeID ='" & OsobljeIDTextBox.Text & "'"]) but with "And" it give err.


Solution

  • Try this:

    Me.Table2BindingSource.Filter = "osobljeID = '" & OsobljeIDTextBox.Text & "' AND Godina >= " & txtGodP.Text
    

    The operator AND should be part of the filter string.