8/14/2003

Single-Character Wildcard And ADO.NET

Why isn't there a single-character wildcard for use in ADO.NET's Expression property?

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.

by Bryan at 11:09:00 AM | | Permalink
Comments (0) | Trackbacks (0)

Comments

Have you got something to say?

Leave a comment below:

Name:*  
Email:*  
Website:
Comment:*  

* Required Field