本文介绍了如何监视通过我的ADO连接发送的SQL命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要拦截在ADO连接组件和数据库服务器之间传递的所有SQL命令。类似于dbExpress的,但适用于ADO。



任何人都知道实现此功能的任何第三方组件?



更新



我想做的是以编程方式(通过代码)从我的应用程序监视SQL语句,而不使用外部工具。对于任何数据库引擎。

解决方案

我找到了一个解决方案,使用事件(发生在数据库服务器发出接受命令执行后)。



更多信息

 程序TDataModuleProd.ADOConnection1WillExecute(
连接:TADOConnection; var CommandText:WideString;
var CursorType :TCursorType; var LockType:TADOLockType;
var CommandType:TCommandType; var ExecuteOptions:TExecuteOptions;
var EventStatus:TEventStatus; const命令:_Command;
const Recordset:_Recordset);
begin
AddLog(CommandText);
结束

我在我的博客上写了一篇小文章,供那些想要更多信息的人。




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.

解决方案

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/

这篇关于如何监视通过我的ADO连接发送的SQL命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 16:45