Error "Incorrect syntax near the keyword 'AND'"
When running the preview in FastReport Designer, it shows the error "Incorrect syntax near the keyword 'AND'" and does not display anything, this happened when acquiring version 2023.1.13 and occurs every time you close a project and reopen it, could you please inform me what can be done so that this error does not occur every time, thank you very much.
This discussion has been closed.
Comments
Hello!
When creating dynamic filter conditions, always start the WHERE clause with a condition that is known to be true:
In this case, even if one of the conditions is omitted or a parameter is empty, the predicate (1=1) is guaranteed to be present before the AND keyword, and a syntax error is prevented.
Set default values for parameters in the Designer:
In the Data window, expand your data source → open the Parameters properties.
For each parameter, specify:
DataType (corresponding to the field type in the database, e.g. VarChar, Int);
DefaultValue (e.g. ALL, 0 or %);
Expression (if the value is to be taken from a report parameter, e.g. [ReportParameter1]).
If filtering is configured at the band level (DataBand.Filter): Ensure that logical expressions use correct C# syntax and check fields for null:
!IsNull(‘Products.Active’) && [Products.Active] == true && ([CategoryId] == ‘ALL’ || [Products.CategoryId] == [CategoryId])