Page 1 of 1

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

Posted: Mon 22 May 2006 08:53
by kelinda72
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

Posted: Mon 22 May 2006 12:11
by Antaeus
> 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.