How to Use MYQuery.SQLDelete........

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
kelinda72
Posts: 9
Joined: Fri 05 May 2006 10:27

How to Use MYQuery.SQLDelete........

Post by kelinda72 » Mon 22 May 2006 08:53

hi

I put in my DataModule a component TMYQUERY that is connect to a database, i insert at DesignTime the sql for deleting record...

DELETE FROM progetti
WHERE
DATAULTA = :Old_DATAULTA

In the avent CLICKBOTTON i want delete all the record in the table.
so i think i have to execute the query.... so i do that...

if not SaJConn.InTransaction then
begin
SaJConn.StartTransaction;
TabDel.SQLDelete.Add(TabDel.SQLDelete.CommaText);

TabDel.Execute;
SaJConn.Commit;
end;

**but i think its no the way......someone can help me?

thanks a lot

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

Post by Antaeus » Mon 22 May 2006 12:11

> In the avent CLICKBOTTON i want delete all the record in the table.
To delete all records from the table you should use something like:

Code: Select all

  MyQuery.SQL.Text := 'TRUNCATE TABLE TableName';
  MyQuery.Execute;
or

Code: Select all

  MyQuery.SQL.Text := 'DELETE FROM TableName';
  MyQuery.Execute;
The first way is quicker. Please read MySQL Server Reference Manual for detailed information.

About options SQLDelete, SQLUpdate, SQLInsert, SQLRefresh you can read in MyDAC Help. Also you can refer to this link.

Post Reply