Delphi IDE (239)
Windows with Delphi (38)
About this site
Links to us
How to set a NULL value through the VCL
1 comments. Current rating: (1 votes). Leave comments and/ or rate it.
I need to set a field in a record back to NULL (not an empty string or 0 for a numeric field).
I know I could run a SQL statement and do something like
'update customers set pid = NULL where cust_id=1234'
How can I do this within a TQuery using .Edit and .Post methods and TField instances to assign values?
To set a field to NULL, you need to use the TField.Clear method. See the code below for an example.
You don't like the formatting? Check out SourceCoder then!
Query1 : TQuery;
Query1.FieldByName('FIRST_NAME').AsString = 'noname';
Fábio from Brazil