开发者

How can I monitor the SQL my Delphi application executes?

Is there a way in Delphi XE to have a开发者_开发知识库n SQL monitor that tracks all SQL done by my application? Delphi 5 had a component for it.


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;


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜