简体   繁体   English

如何在TDataSet中编辑联接表中的数据

[英]How to edit data from the joined table in TDataSet

Let's say i have 1 query, 1 main table and 2 left joins. 假设我有1个查询,1个主表和2个左连接。 Query looks like (for example) 查询看起来像(例如)

SELECT "E.name", 
       D."title" 
  FROM "Employees" AS E 
       LEFT JOIN "Department" AS D 
            ON E."depid" = D."id_dep" 

So now i want to change the information directly in the DBGrid. 所以现在我想直接在DBGrid中更改信息。 I put dataset into Edit mode, but as a result i can only edit columns which refers to Employees table, and not Department. 我将数据集置于编辑模式,但结果我只能编辑引用Employees表的列,而不是Department。

I know, that this method is not very correct, it would be easier and more correct to use UPDATE request, but this is a requirment of the customer. 我知道,这种方法不是很正确,使用UPDATE请求会更容易也更正确,但这是客户的要求。 Thank you for reply 感谢您的回复

Instead of one query you should use two datasets with Master-Detail Relationship to work on each dataset (Create, Read, Update, Delete). 您应该使用两个具有主 - 细节关系的数据集来处理每个数据集(创建,读取,更新,删除),而不是一个查询。

The documentation will guide you on how to Creating Master-Detail Relationships 该文档将指导您如何创建主 - 细节关系

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

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