Page 1 of 1

How to get last executed sql query?

Posted: Fri 12 Sep 2008 12:55
by eimix
Hi

I use EurekaLog, and i want it to add sql query into error report.

Is it possible to get what sql query was send to server from TMyConnection or anythere else?

Thanks,
Eimis

Posted: Mon 15 Sep 2008 09:14
by Dimon
MyDAC doesn't allow getting SQL queries that were sent to server from TMyConnection.
However, you can use the TMySQLMonitor component to monitor dynamic SQL execution in MyDAC based applications. Also you can use the DBMonitor tool.
You can find more detailed information about it in the MyDAC help.

Posted: Mon 15 Sep 2008 12:14
by eimix
DB Monitor is not a solution - EurekaLog cannot take anything from it, and DB monitor is not running on client's PC's.

So i made some workaround - TMySQLMonitor has OnSQL event - i write every SQL into temp var (always overwriting last value).
And if exception is caught by EurekaLog, i use that temp var as last known send SQL to server.

It looks a little bit slow for me,
i did not measured changes in performance, but it this is not a straight forward way i think,

but if there is not anything faster, it suites for me :)