简体   繁体   English

Delphi XE6 FireDac Master Detail错误

[英]Delphi XE6 FireDac Master Detail error

I have two tables in a master Detail relationship. 我有两个主明细关系表。 Using TFDTables. 使用TFDTables。 I display the detail table in a TDBGrid 我在TDBGrid中显示明细表

When I call up the master table I can successfully create one detail record. 调用主表时,我可以成功创建一个明细记录。 When I try to add a second the problem starts. 当我尝试增加一秒钟时,问题开始了。

The system does post the second record to the database but when it adds a new line for the thrid record in the detail grid it fills it with the information from the second record. 系统确实将第二条记录发布到数据库中,但是当它在详细信息网格中为第三条记录添加新行时,它将第二条记录中的信息填充到该行中。 Changing this third records generates an error: 更改此第三条记录将产生错误:

Project xyz.exe raised exception class EFDDBEngineException with message '[FireDAC][Phys][FB]-312. 项目xyz.exe引发了异常类EFDDBEngineException,消息为'[FireDAC] [Phys] [FB] -312。 Exact update affected [2] rows, while [1] was requested'. 确切的更新影响了[2]行,而请求了[1]”。

Further when I click ok in Delphi's debugger it brings up: 此外,当我在Delphi的调试器中单击“确定”时,它会弹出:

Project xyz.exe raised exception class EFDException with message '[FireDAC][DApt]-400. 项目xyz.exe引发了异常类EFDException,消息为'[FireDAC] [DApt] -400。 Update command updated [2] instead of [1] record. 更新命令更新了[2]而不是[1]记录。 Possible reasons: update table does not have a PK or row identifier, record has been changed/deleted by another user'. 可能的原因:更新表没有PK或行标识符,记录已被其他用户更改/删除。

But the changes do get stored in the database as if I changed the second record and the second record in the grid also reflects what is entered in the third record) I realize these are being generated as it tries update the third record which does not exist. 但是更改确实存储在数据库中,就像我更改了第二条记录,并且网格中的第二条记录也反映了第三条记录中输入的内容一样。我意识到这些是在生成的,因为它尝试更新不存在的第三条记录。

When I shut down the program and check the database there are only two records in the database at the saved point of the last post before the error. 当我关闭程序并检查数据库时,在错误之前最后一个帖子的保存点,数据库中只有两条记录。 When I reopen the application the grid show three records with the second and third being identical. 当我重新打开应用程序时,网格显示三个记录,第二个和第三个相同。

Any help or ideas would be greatly appreciated. 任何帮助或想法将不胜感激。

Farley 法利

Probably UpdateOptions.KayFields and UpdateOptions.UpdateTableName will help you. 可能UpdateOptions.KayFields和UpdateOptions.UpdateTableName会为您提供帮助。 Spacify PK field(s) name in KeyFields and table name in UpdateTableName property of TFDTable. 缩小KeyFields中的PK字段名称,并缩小TFDTable的UpdateTableName属性中的表名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM