Wildcard search in dataview

  • Thread starter Thread starter JemPower
  • Start date Start date
J

JemPower

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 said:
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.
 
Back
Top