Page 1 of 1

TMyQuery Execute vs ExecSQL

Posted: Thu 15 Mar 2012 11:27
by lastminute
Hi

Would someone help me to understand the main differences between using something like:

TMyQuery *Q = new TMyQuery(Application);
Q->Connection = conn;
Q->SQL->Add(query);
Q->Execute();
Q->Free();

OR
...
Q->ExecSQL();
...

Assuming "query" will be always an Update, or Delete or Insert statement.

I know Execute does an implicit call to Prepare, is that the only difference between ExecSQL and Execute?

Thanks
Javier

Posted: Thu 15 Mar 2012 12:56
by AndreyZ
Hello,

There is no difference between the TMyQuery->Execute() and TMyQuery->ExecSQL() methods, the TMyQuery->ExecSQL() method internally calls the TMyQuery->Execute() method. The TMyQuery->ExecSQL() method is added for compatibility with the TQuery component.

Posted: Thu 15 Mar 2012 13:39
by Justmade
Or it is more simple to directly execute the statement with no result dataset using :

conn->ExecSQL('Your statement');

Posted: Thu 15 Mar 2012 14:04
by lastminute
Thanks a lot for your prompt response