Delete

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
rvzip64
Posts: 17
Joined: Wed 19 Sep 2007 08:51

Delete

Post by rvzip64 » Fri 05 Oct 2007 08:18

Hi everybody,

I have a MyQuery on my form, which send 500 rows after my query.

I would like to delete all this row.

How can i do this ?

I must analysis the dataset of myquery with a loop, and execute a delete for each row ?

Or it is possible to connect directly the Mycommand(or another component) on myquery ?

Rgds

Hervé

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 08 Oct 2007 09:19

If you need to delete all records in a server table, the fastest way to do it is to execute the TRUNCATE TABLE command.
If you restricted records requested from a table using a WHERE condition, the fastest way to delete them is to execute the DELETE command with the same WHERE clause. You can create an additional TMyCommand object, or use the TMyConnection.ExecSQL method to execute these commands.
If these two ways do not suit you, you should call the Delete method of your dataset for each record.

Post Reply