Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RowFilter with apostrophe
Message
From
23/03/2005 10:09:44
 
 
To
23/03/2005 08:39:41
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP1
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
00998377
Message ID:
00998415
Views:
42
Rick,

Just like in SQL, you have to use two single quotes:
string x = "O''Brien";
MyView.RowFilter = "Name = '" + x + "'";
~~Bonnie




>I've constructed a search tool to retreive subsets of data from an ADO.NET dataset. I construct a DataView and then set the RowFilter property to a value entered into a search for text box. Unfortunately, if the user is searching for anyone named "O'Brien" the apostrophe causes an error. I have been able to trap for other reserved characters (wild cards like % and *) by enclosing them in brackets but the only way I have been able to prevent a crash is by removing any apostrophe from the rowfilter string.
>
>Is there any way to allow the dataview to filter for strings that INCLUDE the apostrophe? This is not a SQL error since I can construct a SQL SELECT which will include the apostrophe.
>
>Thank you.
>
>Rick Grinter
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform