DelphiFAQ Home Search:
General :: Programming :: Delphi :: Database
Database development with Delphi. Includes issues with BDE, ADO and InterBase.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

How to set a NULL value through the VCL


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.

   Query1 : TQuery;
   Query1.FieldByName('FIRST_NAME').AsString = 'noname';
   Query1.FieldByName('P_ID').Clear;  // set this field to NULL
You don't like the formatting? Check out SourceCoder then!
Generated 0:01:08 on Nov 15, 2019