Wildcard search in dataview

Discussion in 'ASP .Net' started by JemPower, Oct 24, 2003.

  1. JemPower

    JemPower Guest

    Hi all,

    Can someone tell me if it's possible to search through a dataview based on a
    part-filter.

    For example, if I use...

    Dim dvAvailable = New DataView(dsRecipients.Tables("Available"),
    "name='%jo&'","", DataViewRowState.CurrentRows)

    It would return

    John

    Jonathon

    Joanne

    Jody

    Jon

    etc.

    The only way I can seem to do it is by using an exact match, not a 'part-of'
    match.



    Any ideas?

    TIA
    JemPower, Oct 24, 2003
    #1
    1. Advertising

  2. JemPower

    Jim Nugent Guest

    "JemPower" <noemailspecified> wrote in message
    news:...
    > Hi all,
    >
    > Can someone tell me if it's possible to search through a dataview based on

    a
    > part-filter.
    >
    > For example, if I use...
    >
    > Dim dvAvailable = New DataView(dsRecipients.Tables("Available"),
    > "name='%jo&'","", DataViewRowState.CurrentRows)
    >
    > It would return
    >
    > John
    >
    > Jonathon


    Yes, you can. I tried it and it works, but I don't see where or why you
    would use the '&' character. I tried this: "title like '%Computer%'" and it
    returned only book titles (from the titles table in the pubs sample) with
    that word in them. It also hit on 'Computers' as expected.

    This is from MSDN for VS.Net 2003
    ___________________________________________________________
    WILDCARD CHARACTERS

    Both the * and % can be used interchangeably for wildcards in a LIKE
    comparison. If the string in a LIKE clause contains a * or %, those
    characters should be escaped in brackets ([]). If a bracket is in the
    clause, the bracket characters should be escaped in brackets (for example
    [[] or []]). A wildcard is allowed at the beginning and end of a pattern, or
    at the end of a pattern, or at the beginning of a pattern. For example:

    "ItemName LIKE '*product*'"

    "ItemName LIKE '*product'"

    "ItemName LIKE 'product*'"

    Wildcards are not allowed in the middle of a string. For example, 'te*xt' is
    not allowed.

    ____________________________________________________

    These expression are a subset of SQL expressions.
    --
    Jim (for e-mail replace invalid with com)
    "Remember, an amateur built the Ark; professionals built the Titanic."
    Jim Nugent, Nov 9, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bengt Richter
    Replies:
    0
    Views:
    518
    Bengt Richter
    Aug 3, 2003
  2. CodeMonkey
    Replies:
    1
    Views:
    721
    joyal jhaveri
    Feb 4, 2011
  3. Gerhard Häring

    Re: Recursive wildcard file search

    Gerhard Häring, Jul 4, 2008, in forum: Python
    Replies:
    0
    Views:
    368
    Gerhard Häring
    Jul 4, 2008
  4. Simon Brunning

    Re: Recursive wildcard file search

    Simon Brunning, Jul 6, 2008, in forum: Python
    Replies:
    0
    Views:
    358
    Simon Brunning
    Jul 6, 2008
  5. Replies:
    7
    Views:
    820
Loading...

Share This Page