Saturday, February 02, 2008

System.Data.EvaluateException

Problem: You are using Select Method to retrieve rows from a typed DataTable and you keep getting the fallowing exception:

 System.Data.EvaluateException: Cannot perform '=' operation on System.String and System.Int32.

This isn't the most helpful error message.

Solution: You are missing hyphens.

Example:

Wrong:

CustomerRow[] rows = Select(string.Format("LastName = {0}", LastName)) as CustomerRow[];

Right:

CustomerRow[] rows = Select(string.Format("LastName = '{0}'", LastName)) as CustomerRow[];

#     Comments [1]  
kick it on DotNetKicks.com