如何跟踪应用程序执行的SQL语句

superfireware 2013-12-18 02:20:11
如何跟踪Delphi应用程序和数据库交互的SQL语句内容,使用TSQLMonitor只能获取到SQL语句,不能获取到参数值。以下是某程序SQL跟踪器的示例。

Select StoreLocID, QtyUnit, CostPrice, AmtBlc, QtyBlc
from Stgenleg
where Sysid=? and AccYear=? and AccMonth=?
and Itemid=?
PARAMCOUNT = 4, Owner = (UnNamed: TSQLQuery)
PARAMS[0] : Name = Sysid , DataType = Integer , Value = "1"
PARAMS[1] : Name = AccYear , DataType = Integer , Value = "2013"
PARAMS[2] : Name = AccMonth, DataType = Integer , Value = "11"
PARAMS[3] : Name = Itemid , DataType = Integer , Value = "484"
...全文
378 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
superfireware 2013-12-26
  • 打赏
  • 举报
回复
引用 1 楼 kiboisme 的回复:
type
  TADOQueryHook = class(TADOQuery);
function GetSetActiveAddr : Pointer;
begin
  Result := @TADOQueryHook.SetActive;
end;
//用GetSetActiveAddr得到SetActive过程的地址,然后用InLine_HOOK,新入口格式如下:

procedure NewSetAvtiveProc(Self : TDataSet; Value : Boolean);
begin
  if Value and (PPointer(Self)^ = TADOQuery) then begin
    ShowMessage(TADOQuery(Self).SQL.Text);
  end;
end;
入行太浅没看懂,给分结贴
蓝色光芒 2013-12-19
  • 打赏
  • 举报
回复
type
  TADOQueryHook = class(TADOQuery);
function GetSetActiveAddr : Pointer;
begin
  Result := @TADOQueryHook.SetActive;
end;
//用GetSetActiveAddr得到SetActive过程的地址,然后用InLine_HOOK,新入口格式如下:

procedure NewSetAvtiveProc(Self : TDataSet; Value : Boolean);
begin
  if Value and (PPointer(Self)^ = TADOQuery) then begin
    ShowMessage(TADOQuery(Self).SQL.Text);
  end;
end;

2,495

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧