I am trying to开发者_开发知识库 make this work but have been unlucky it is giving me th following error
Error in Like operator: the string pattern '%testing : | / - “ ‘ & * # @%' is invalid.
This search works as long as it doesnt contain a string as the one above.. This is my code for the search
DataRow[] rows = GetAllItems.Select("Name like '%" + cleanedText + "%'");
I tried - Modified per cHaos (still errors though)
string cleanedText = SearchText.Replace("\"", "\\\"").Replace("'", "''");
but no luck when i enter the following string in the search although i know it is in the data
testing : | / - “ ‘ & * # @%
Anyone has a nice suggestion
Thank you
Both % and * can be used interchangeably for wildcard characters in the LIKE comparison.
As such you will need to enclose these characters in square brackets in your expression string like so:
Name like '%testing : | / - “ ‘ & [*] # @%'
See DataColumn.Expression.
From the above link:
Wildcard Characters
Both the * and % can be used interchangeably for wildcard characters in a LIKE comparison. If the string in a LIKE clause contains a * or %, those characters should be enclosed in brackets ([]). If a bracket is in the clause, each bracket character should be enclosed in brackets (for example [[] or []]).
精彩评论