System.Data.EvaluateException

02.01.08

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[];