TMyQuery->ExecSQL() substitute?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Minotaurus007
Posts: 14
Joined: Wed 27 Aug 2008 16:03

TMyQuery->ExecSQL() substitute?

Post by Minotaurus007 » Fri 29 Aug 2008 14:47

For SELECT-statements I use

Code: Select all

MyQuery1->Open();
For UPDATE-statements I used to use

Code: Select all

MyQuery1->ExecSQL();
in another software package.
Switching to MyDAC however, this method seems to be not available. What is the correct method to run UPDATE statements after creating an SQL-String like

Code: Select all

 MyQuery1->SQL->Text = "UPDATE table SET column = 1 WHERE ...";
Being unsure now I tried MyQuery1->Execute(); but I'd appreciate to get some valid advice.

-Mino

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Re: TMyQuery->ExecSQL() substitute?

Post by eduardosic » Fri 29 Aug 2008 17:47

Minotaurus007 wrote:For SELECT-statements I use

Code: Select all

MyQuery1->Open();
For UPDATE-statements I used to use

Code: Select all

MyQuery1->ExecSQL();
in another software package.
Switching to MyDAC however, this method seems to be not available. What is the correct method to run UPDATE statements after creating an SQL-String like

Code: Select all

 MyQuery1->SQL->Text = "UPDATE table SET column = 1 WHERE ...";
Being unsure now I tried MyQuery1->Execute(); but I'd appreciate to get some valid advice.

-Mino
You can use MyQuery1.Execute for all SQL (Selec, Update, Delete, Create... )

see MyDAC Help;

Code: Select all

Description

Use Execute to execute the SQL statement on the server. If SQL statement is a query, Execute calls Open method.

Execute implicitly prepares the SQL statement by calling Prepare method if AutoPrepare option is set to True and the statement has not been prepared yet. To speed up  the performance in case of multiple Execute calls, an application should call Prepare before calling Execute method for the first time.

Minotaurus007
Posts: 14
Joined: Wed 27 Aug 2008 16:03

Post by Minotaurus007 » Fri 29 Aug 2008 18:20

You can use MyQuery1.Execute for all SQL (Selec, Update, Delete, Create... )
Thx, Eduard. I was confused because for UPDATE queries MYSQL explicitely requires ExecSQL(). Execute() works in MyDAC for me now.

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Post by eduardosic » Fri 29 Aug 2008 18:24

Minotaurus007 wrote:
You can use MyQuery1.Execute for all SQL (Selec, Update, Delete, Create... )
Thx, Eduard. I was confused because for UPDATE queries MYSQL explicitely requires ExecSQL(). Execute() works in MyDAC for me now.
No problems this is normal when starting with MyDAC.

goog look :D

Post Reply