Re: Error in RowFilter Like Operation

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 03/27/04


Date: Sat, 27 Mar 2004 12:26:19 -0000

King Kong <kfnwNOSPMZZ@hotmail.com> wrote:
> I am facing misterious problem while setting up RowFilter property of
> DataView.

It's not that mysterious really :)
 
> It works find when i do
>
> dv.RowFilter = "StudentName like 'Dave'"
> or
> dv.RowFilter = "StudentName like '%Dave'"
>
> but it breaks up when i do
> dv.RowFilter = "StudentName like 'Da%v%e'"
> or use wild cards, or repeat the above case.

Yup. From the documentation for DataColumn.Expression (linked from
DataView.RowFilter):

<quote>
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.
</quote>

Basically, it's much more restrictive than SQL Server, which is fair
enough really, IMO. I just wish you could specify a delegate to use for
filtering, rather than just a text string. That would make it *much*
more powerful.

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • Regex problem.
    ... I need to parse a String and replace everything within ... brackets with the String "xx". ... this pattern works fine if there is only one set of brackets in my ...
    (comp.lang.java.programmer)
  • Re: Predicting the Future and Kolmogorov Complexity
    ... Predictability is based on the pattern itself. ... addition to the string. ... For any prediction scheme, there are computable strings that show no ... Out of this hole comes a ~2 cm blue marble followed by a red ...
    (talk.origins)
  • Re: macro for parsing text
    ... SUB will remove from any cell selected the pattern as you described (i.e. ... Dim c As Range ... Dim Temp As String ... Dim colMatches As MatchCollection ...
    (microsoft.public.excel.programming)
  • Re: macro for parsing text
    ... SUB will remove from any cell selected the pattern as you described (i.e. ... Dim c As Range ... Dim Temp As String ... Dim colMatches As MatchCollection ...
    (microsoft.public.excel.programming)
  • Re: Entropy in crystalization: up or down?
    ... such a pattern as "artifact" has exactly the same fundamental basis ... for accepting a certain type of narrow band radiosignal as artifact. ... and *that* is the reason that induction on a data string alone is worthless. ... over and over again, in radiosignals. ...
    (talk.origins)