Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 14th, 2009, 11:12 AM
Authorized User
Join Date: Mar 2005
Posts: 36
Thanks: 2
Thanked 1 Time in 1 Post
Default System.Data.EvaluateException


I have a requirement, where in user types in a value and I use this value to filter my datatable and show the records to the user.

Below is the query.
strQueryExpression = "GradeDesc LIKE '" + strValue + "%'"; //strValue = the typed in value.
drFilteredRows = dtSourceDataTable.Select(strQuery);

While testing I typed a text like this "Shell[%%" and I got exceptions as below.

System.Data.EvaluateException Message: Error in Like operator: the string pattern 'Shell[%%' is invalid. Data: System.Collections.ListDictionaryInternal InnerException: NULL TargetSite: System.String AnalizePattern(System.String)

After analyzing and searching I found some solutions. Now I am replacing some of the characters woth proper escape characters. as below.
strValue = e.Text.Trim().Replace("'", "''"); //' is replaced by ''
strValue = strValue.Replace("[", "[[]");

But this is defenitely not sufficient.

For example when I type "Shell&*" or "Shell&" it works fine but when I type like this "Shell*&" this through the exception. How can I make handle these combination of characters?

Can any one help me in this regard?
Old April 22nd, 2009, 12:26 PM
Authorized User
Join Date: Mar 2005
Posts: 36
Thanks: 2
Thanked 1 Time in 1 Post

Any help for this query?

Similar Threads
Thread Thread Starter Forum Replies Last Post
System.Data.EvaluateException abinashpatra ASP.NET 2.0 Professional 0 April 14th, 2009 04:25 AM
System Data Types liamfitz Beginning VB 6 0 October 17th, 2006 05:31 PM
System.Data.SqlClient.SqlException kbarsi Beginning VB 6 2 August 13th, 2005 09:39 PM
Need Help in System.Data.SQL vavre ADO.NET 2 August 24th, 2003 10:28 AM
'System.Data.ConstraintException' - HELP PLEASE AlanBell ADO.NET 1 July 1st, 2003 02:23 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.