How can I monitor the SQL commands send over my ADO connection?
ado, delphi, trace
Solution
I found a solution, use the event TAdoConnection.OnWillExecute (Wich occurs after a database server signals acceptance of a command execution. )
More info here
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
AddLog(CommandText);
end;
I wrote a small article on my blog, for those who want more information.
http://theroadtodelphi.wordpress.com/2010/02/21/build-your-own-profiler-using-ado/
Problem
i need intercept all the SQL commands that pass between an ADO connection component and a database server. something like the TSQLmonitor of dbExpress, but for ADO . Anybody know any third-party component that implements this functionality? UPDATE I want to do is to monitor the SQL statements programmatically (by code) from my application without using an external tool. for any database engine.