Wildcard search in dataview

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
 
J

Jim Nugent

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top