[英]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 XE 中有没有办法让 SQL 监视器跟踪我的应用程序完成的所有 SQL? Delphi 5 had a component for it.
Delphi 5 有一个组件。
As already suggested here you might use TAdoConnection.OnWillExecute event to send queries to the console, eg: 如此处已建议的那样,您可以使用TAdoConnection.OnWillExecute事件将查询发送到控制台,例如:
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.如果您使用 devart unidac 组件进行数据库操作,它们有完美的工具: https://www.devart.com/dbmonitor/其他选择是为您正在使用的 SQL 组件编写包装器,并将所有信息写入您的日志文件自己。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.