ADODataSet从连接表中删除 [英] ADODataSet deleting from joined table

查看:161
本文介绍了ADODataSet从连接表中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Delphi应用程序,其中显示了从以下查询中播放的游戏列表:

I have a Delphi app where I display a list of games that have been played from a query like this:

select  g.*, gt.id, gt.descr 
from GAMES g 
inner join game_types gt on gt.id = g.game_type
order by game_date DESC

当我点击DBNavigator中的删除按钮时,来自game_types表的加入记录也被删除。这是一个问题,因为许多其他游戏可以是相同的类型。

When I click the delete button in the DBNavigator, the joined record from the game_types table is also deleted. That's a problem because many other games can be of the same type.

我需要做什么来使它只有游戏被删除,但不是游戏类型?

What do I need to do to make it so that only the game is deleted but not the game type?

推荐答案

您需要使用唯一表动态属性

ADOQuery1.Properties['Unique Table'].Value := 'GAMES';

MSDN ADO文档


如果设置了唯一表动态属性,并且Recordset是在多个表上执行JOIN操作的
结果,则
Delete方法将仅从唯一的表中指定的表中删除行
表属性。

If the Unique Table dynamic property is set, and the Recordset is the result of executing a JOIN operation on multiple tables, then the Delete method will only delete rows from the table named in the Unique Table property.

这篇关于ADODataSet从连接表中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆