DataView filters with wildcards

D

DotNetJunkies User

I have data in my DataTable that lists multiple values in the Roles column which are space separated like this:
" AM AMB MCS DIO CO PM3 CAM "

I need to be able to query on this column to get back a list of rows such that the Roles are "AM" or "MCS":
strFilter = "(Roles like '* AM *' or Roles like '* MCS *')"

[Example dataview statement:
dv = new DataView(dTable, strFilter, strSort, DataViewState.CurrentRows)]

The hard part here is that I DON'T want "CAM" or "AMB" when I search for "AM" and that "AM" may be at the start or end of the column string value, hence the extra character (space) marking the beginning and ending of each value.

The query above works on the dataset in an Access database, but when I apply it using the filter string of the dataview (to populate a drop list on the fly) the space AFTER "AM" causes no results returned.

ALSO, I have similar problems trying to filter using wildcards WITHIN the string. Ex: in Access "D?O" would return "DIO", "DKO", "DJO", but not in this context.

Are there any suggestions or fixes for resolving these problems?
 

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,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top