The error points to the place where the LINQ query is evaluated and, as the message says, the problem is that a character is expected but several characters were provided.
Check whenever ddl_AreaFilter.SelectedValue
, ddl_SubAreaFilter.SelectedValue
or ddl_AllocFilter.SelectedValue
actually contain a character or a string. If they contain more than one character, you should replace '
with \"
when building the where
condition, for instance:
WhereBuild.Append("Area = """ & ddl_AreaFilter.SelectedValue & """")
EDIT
You must make sure that the type of the value contained in each SelectedValue
string match the corresponding database type. For instance, if the database column is a numeric type, the string content will be casted to a numeric type.
When you specify the value in the comparison using quotes, you are indicating that the type on the right side of the comparison is either character or string (depending on whenever you use single or double quotes, respectively).
So, what are the Area
, SubArea
and Allocation
types in the database?
- Single character: the value in your query should be around single quotes:
Area = 'value'
- Strings (for instance,
varchar
):you must use double quotes:Area = "value"
- Other: then you should use no quotes:
Area = value