Using Delphi Xe2 and v2.2.5 of LiteDAC Professional and can't seem to figure how to auto populate a DateTime field when inserting a new record into my SQLite table.
For example when using the DBNavigator control to Insert & Post or Edit & Post, etc.
I'm using TLiteQuery, TLiteDataSource along with TCRDDBGrid.
My form also has various DB Control controls like TDBEdit and DBNavigator.
I tried researching online and attaching code to the various events in the controls but I am still stumped.
Edit:
I was assuming that I could do this via code, is this something that must be done using triggers?
Any help would be appreciated.
How to auto populate on DateTime on insert or update?
Re: How to auto populate on DateTime on insert or update?
Hello,
In order for the field to be filled in automatically on inserting a new record, you should set the default value for this field on table creation, as well as enable the DefaultValues option
In order for the field to be filled in automatically on inserting a new record, you should set the default value for this field on table creation, as well as enable the DefaultValues option
Code: Select all
CREATE TABLE test (id INT, data TIMESTAMP DEFAULT current_timestamp);
Code: Select all
LiteQuery1.Options.DefaultValues := True;