Default Field Value

Discussion of open issues, suggestions and bugs regarding LiteDAC (SQLite Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
m227
Posts: 59
Joined: Mon 06 Aug 2007 12:41

Default Field Value

Post by m227 » Tue 29 Dec 2015 22:47

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

MaximG
Devart Team
Posts: 1030
Joined: Mon 06 Jul 2015 11:34

Re: Default Field Value

Post by MaximG » Wed 06 Jan 2016 14:04

To use the default values, use the DefaultValues property. (https://www.devart.com/litedac/docs/?de ... values.htm) :

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

Post Reply