Gwenael
Gwenael

Reputation: 137

How can I monitor the SQL my Delphi application executes?

Is there a way in Delphi XE to have an SQL monitor that tracks all SQL done by my application? Delphi 5 had a component for it.

Upvotes: 4

Views: 2266

Answers (2)

Janis T
Janis T

Reputation: 1083

If you use devart unidac components for database operations, they have perfect tool for that: https://www.devart.com/dbmonitor/ Other option would be to write wrappers for SQL components you are using and write all info into log file your self.

Upvotes: 0

Michał Turecki
Michał Turecki

Reputation: 3167

As already suggested here you might use TAdoConnection.OnWillExecute event to send queries to the console, eg:

procedure TDataModuleProd.ADOConnection1WillExecute(
  Connection: TADOConnection; var CommandText: WideString;
  var CursorType: TCursorType; var LockType: TADOLockType;
  var CommandType: TCommandType; var ExecuteOptions: TExecuteOptions;
  var EventStatus: TEventStatus; const Command: _Command;
  const Recordset: _Recordset);
begin
  {$ifdef DEBUG}
     OutputDebugString(PChar('SQL Execute: ' + CommandText));
  {$endif}
end;

Upvotes: 2

Related Questions