Page 1 of 1

Default Field Value

Posted: Tue 29 Dec 2015 22:47
by m227
Dear Sirs,
I have simple table:

Code: Select all

CREATE TABLE Files (
  Name       CHAR(28) NOT NULL,
  Downloaded BOOL NOT NULL DEFAULT False
);
when I try to populate data from code in runtime assigning only Name field with code:

Code: Select all

      begin
        ltFiles.Append;
        ltFiles.FieldByName('Name').AsString  := FileName;
        ltFiles.Post;
      end;
I get an error:
First chance exception at $7723C42D. Exception class EDatabaseError with message 'Field 'Downloaded' must have a value'.

Why the DEFAULT field value is not used instead?
Michal

Re: Default Field Value

Posted: Wed 06 Jan 2016 14:04
by MaximG
To use the default values, use the DefaultValues property. (https://www.devart.com/litedac/docs/?de ... values.htm) :

...
ltFiles.Options.DefaultValues := True;
...