Board index » delphi » Delete row from TDBGrid, create with TQuery

Delete row from TDBGrid, create with TQuery

I use TQuery (Oracle table) and show data in TDBGrid object.
When I want to delete a row from the Grid, the row will be deleted just
in grid, not in database. For browsing and deleting rows I use
TDBNavigator.
If I want to delete the row in database i use TUpdateSQL.Apply(ukDelete)
function, which have right SQL statement. It deletes the row from
database.
But the problem is, that function deletes the next row from the grid,
not the selected.

Where is the problem!

Thanks, David

 

Re:Delete row from TDBGrid, create with TQuery


a. Try adding your code to the BeforePost and BeforeDelete event handler
instead of to AfterPost and AfterDelete.

or

b. Set CachedUpdates=True + UpdateObject=YourUpdateSQL and do ApplyUpdates
in the AfterPost and AfterDelete.

"David Plosinjak" <david.plosin...@probanka.si> schreef in bericht
news:391A6933.1E5F2D1B@probanka.si...

Quote
> I use TQuery (Oracle table) and show data in TDBGrid object.
> When I want to delete a row from the Grid, the row will be deleted just
> in grid, not in database. For browsing and deleting rows I use
> TDBNavigator.
> If I want to delete the row in database i use TUpdateSQL.Apply(ukDelete)
> function, which have right SQL statement. It deletes the row from
> database.
> But the problem is, that function deletes the next row from the grid,
> not the selected.

> Where is the problem!

> Thanks, David

Other Threads