DBPlanner.PopupPlannerItem.Update - Field '' not found

I study and try DBPlanner.I use FireDAC.
...Color1Click
...
dbpl1.PopupPlannerItem.Update;

D.Locate(KeyField,FPlanner.Items.DBItem.DBKey,[]);   //  DBPlanner Row 2250
          IDPLANNERS                  1           //  Both OK

Debugger Exception Notification

Project Pokusy.exe raised exception class EDatabaseError with message 'fdtblPlanner: Field '' not found'.
WHY?

CREATE TABLE PLANNERS (
IDPLANNERS PRIMARYKEY NOT NULL,
STARTTIME STAMP NOT NULL,
ENDTIME STAMP NOT NULL,
...

You did not setup DBxxxSource.KeyField?

I set it up.
2020 12 29 22 10 06

Clearly KeyField is empty here.
I cannot reproduce such issue when KeyField is setup.
Please isolate this and provide a sample source project with which this can be reproduced.

I follow Demo16.
I use Firebird. I'll try it with your mdb.

During the preparation, I threw away everything redundant. It's already working. I don't know where the problem was.

I have a problem changing the record - Edit.

procedure TfrmUser.dbdysrc1FieldsToItem(Sender: TObject; Fields: TFields; Item: TPlannerItem);
begin
if not Fields.FieldByName('COLOR').IsNull then
begin
Item.Color := TColor(Fields.FieldByName('COLOR').AsInteger);
Item.CaptionBkg := Item.Color;
Item.DBKey := Fields.FieldByName('IDPLANNERS').AsString;
end;
end;

procedure TfrmUser.dbdysrc1ItemToFields(Sender: TObject; Fields: TFields; Item: TPlannerItem);
begin
fdtblPlanner.UpdateTransaction.StartTransaction;
Fields.FieldByName('IDPLANNERS').AsInteger := StrToInt(Item.DBKey); // The value is OK
Fields.FieldByName('COLOR').AsInteger := Integer(Item.Color); // The value is OK
end;

Project Pokusy.exe raised exception class EFDDBEngineException with message '[FireDAC][Phys][FB]-312. Exact update affected [0] rows, while [1] was requested'.

[FireDAC][DApt]-400. Update command updated [0] instead of [1] record. Possible reasons: update table does not have PK or row identifier, record has been changed/deleted by another user.

I don't know where to end the transaction - Commit. Nothing is auto.

All your examples are done with Access (DB, DBF). He doesn't know the transactions. It would be useful to do examples with FireDAC + transactions.

I can solve the problem using SQL, but it's unnecessary extra work.

The automatic updating via databinding is not designed for starting transactions from the event OnItemToFields.

How do I do it right? Principle.

The built-in automatic dataset binding does not use transactions.
If you want to use a custom databinding method, demo 28 shows how this can be done using SQL directly.

Well thank you. I know about demo28. I was hoping it could be done directly, without SQL.

I suggest you change the names of the demo folders.

  1. You used numbering 1 - 9 instead of 01 -09. You've been confusing the directories
  2. Directory names say nothing. I did not come across their list with an explanation of what they contain. So every user has to find out bloodily :hot_face:
  3. Examples of names: Demo18 -> DemoDBDay_Basic, Demo28 -> DemoDBDay_SQL

Content table of demos with description is here under Demos

OK

I guess I found out. I put all TDB...Source on the form. But I set the KeyField to only one - active (linkage to TDBPLanner).