Results 1 to 5 of 5

Thread: bindingsource.filter

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    31

    Cool bindingsource.filter

    Code:
    AgencyId like '528%' and ResourceTypeId = '7'
    I want to pass the above string as filter for the bindingsource but everytime it gives an error.

    The error is :

    Cannot perform 'Like' operation on System.Int16 and System.String.

    Any help is highly awaited

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: bindingsource.filter

    The LIKE operator is only for text columns. As the error message says, it can't compare a Short and a String using LIKE.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: bindingsource.filter

    I've never tried but you may well be able to do this:
    Code:
    CONVERT(AgencyId, 'System.String') LIKE '528%'
    As the documentation for for the Filter property states, the legal syntax is detailed in the documentation for the DataColumn.Expression property.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    31

    Re: bindingsource.filter

    Thanks to all replies
    I have resolved the problem. Problem resolved but i do not know how to mark the thread as resolved. please help

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: bindingsource.filter

    Use the Thread Tools menu above the first post.

    By the way, did you use the code I suggested?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width