0

I need to use a BindingSource Filter property to search for names in a string field. That is easy enough, unless the name contains a single quote (apostrophe) such as "O'BRIEN" or similar names. VS Help says special characters should be escaped by enclosing them in square brackets. This works for some characters such as %, \ and even the bracket characters themselves, but it fails with a syntax error if I attempt to escape a single quote. I also tried to escape using \ but that doesn't work either.

Does anyone know of a way to use expressions to search for strings containing single quotes?

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by fishsqzr
0

Hi,

simply replace one apostrophe by two apostrophes like:

string sFilter = "something apostophe'd";
string myFilter = sFilter.Replace("'","''");

Hope that helps

0

Well, I was sure I'd tried that, but I was wrong - that works. Thanks.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.