Removing ADODataSet from a join table

I have a Delphi application where I show a list of games that were played from such a request:

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 

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

What do I need to do to make sure that only the game is deleted, but not the type of game?

+5
source share
2 answers

You need to use the dynamic property Unique Table

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

From MSDN ADO Documentation

If the dynamic property Unique Table is set, and the recordset is the result of the JOIN operation on several tables, then the Delete method will delete only the rows from the table specified in the Table property.

+10
source

You need to set the TADODataset Unique Table property after opening your dataset.

 ADODataset.Properties['Unique Table'].Value := 'GAMES'; 
+6
source

All Articles