Page 1 of 1

Delete

Posted: Fri 05 Oct 2007 08:18
by rvzip64
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é

Posted: Mon 08 Oct 2007 09:19
by Antaeus
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.