I'm using Delphi 6XE, with MySQL as database server.
I have table's fields as shown below
I'm using FireDAC.
I'm trying to implement data validation using TField.CustomConstraint
, so I use the Field Editor to generate TField
descendant objects as shown below
I have setup field's property using Object Inspector
With browsing from Google, and documentation, the authers give example to use like CustomConstraint := 'x>1000';
I tried with x
but all data were not displayed when running the program, so I switched to use field name instead. But anyway I still can input any data I want, no validations were applied at all.
Please advise how to setup data validation in Delphi. Thanks.
Set the ConstraintsEnabled
property of your FDQuery1
component to True. The reference says the following about this property:
Specifies whether the dataset performs constraint checking.
Use ConstraintsEnabled to get or set the flag that controls the automatic record-level constraints enforcement. When ConstraintsEnabled is False (the default), the dataset does not check Constraints. This allows the dataset to perform large data updates without the overhead of checking constraints. When ConstraintsEnabled is True, the dataset checks Constraints at the end of data editing (Post / AppendRecord / InsertRecord).