Wrox Programmer Forums
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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, 04:25 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(strQueryExpression );

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("'", "''");
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?

Similar Threads
Thread Thread Starter Forum Replies Last Post
System.Data.OleDb.OleDbException: No value given f tjgrindsted ASP.NET 2.0 Basics 0 January 24th, 2007 07: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.