开发者

How can I monitor the SQL my Delphi application executes?

开发者 https://www.devze.com 2023-03-28 22:23 出处:网络
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.O

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

精彩评论

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