Single-Character Wildcard And ADO.NET
by Bryan on 8/14/2003 at 11:09 AM
in Developer Stuff
Why isn't there a single-character wildcard for use in ADO.NET's Expression
I came across this recently when I needed to filter a DataView (using the RowFilter
property of the DataView
) so that only records containing Value LIKE '2__' (underscore is single-character wildcard in T-SQL). This way I get 200, 201, 202, 203,..., 299, but not 2000, etc.
After a thorough review of the MS docs and my ADO.NET book from Wrox (which incorrectly states that * is for single character wildcards), I decided to just use the LEN() function available in Expressions and limit my results to LEN(Value) = 3 (based on example above).
Then end result is something like this:
MyDataView.RowFilter = "Element='Topic' AND Value LIKE '" & Chapter & "%' AND LEN(Value) = " & TopicNumberLength
Sure would have been nicer to just have a single-character wildcard.