A Delphi TClientDataset gotcha – key violation error when using master-detail datasets

If you create a TClientDataset and make it a detail dataset of a master-detail link by setting its master properties, when you run your app and navigate through the Master dataset, the default settings will create a Key Violation error.

This is easily remedied by setting your detail TClientDataset.packetRecords to -1.

For some reason, every time you make a change to the master properties of this dataset, Delphi reverts the packetRecords back to zero which will cause the key violations.

This entry was posted in Delphi and tagged , , . Bookmark the permalink.

Leave a Reply