Page 1 of 1
					
				PgSQLMonitor - What is wrong ?
				Posted: Tue  02 Nov 2010 20:14
				by yapt
				Hello,
I have a problem and I don't know how to "around it".
I have:
* 1 DataModule with:
+-- PgConnection (Debug = true).
+-- PgSQLMonitor (Active = true, Options = all true except moHandled).
* 1 form with:
+-- TPgQuery (Debug = true, associated with datamodule.PgConnection).
+-- I have included PgDacVcl in the uses clause (interface).
After that, I start dbMonitor and AFTER my application.... But I cannot debug that Query.  Nothing is showed in the DbMonitor window, only:
* Processes:
+--  My App. name.
* Events:
+-- PgDAC monitoring is started.
+-- PgDAC monitoring is finished.
 
I don't know what more I must to do to get it to run.  I have tried to emulate environment in a simple project and all runs fine and dbmonitor show SQL information.
But I cannot reproduce my real-application behaviour.
Any idea ?   Any clue ?
PS: In this application, I have a PgSQLMonitor and PgConnection in a datamodule and another datamodule with its own PgSQLMonitor and PgConnection.  I mean, I have two datamodules and this form has both of them in its uses clauses....
But nothing runs
 
			
					
				
				Posted: Wed  03 Nov 2010 08:02
				by AlexP
				Hello,
Unfortunately I also can't reproduce the problem.
Please check that your TPgConnection appears in the Object Tree window in dbMonitor and that PgConnection is connected to a database.
And check that you have the latest version of dbMonitor.
			 
			
					
				
				Posted: Wed  03 Nov 2010 16:11
				by yapt
				Hello, my checks:
1.- PgConnection does NOT appear in the object tree window.
2.- I do suppose PgConnection is connected because my TPgQuery object is associated to that PgConnection.
3.- I was using 3.0.2 dbmonitor version.  I have upgraded to 3.0.3 but it is the same.
A Hint:  If I set active=true my TPgQuery with DbMonitor active, I can see debug process (the Query Execute window and the query in DbMonitor).   
I cannot see it If I execute (run) the application from Delphi IDE.
			 
			
					
				Solved.
				Posted: Wed  03 Nov 2010 19:20
				by yapt
				Hello, it is solved:
the hint was on my first post (PS, Post Scriptum):
PS: In this application, I have a PgSQLMonitor and PgConnection in a datamodule and another datamodule with its own PgSQLMonitor and PgConnection. I mean, I have two datamodules and this form has both of them in its uses clauses....
But nothing runs
It seems _ONLY_ the first one PgSQLMonitor loaded is the ONLY ONE can be activated and "traced".
Therefore how my other datamodule was loaded first and its PgSQLMonitor was not active I couldn't see anything.  So I have deleted my second PgSQLMonitor in my second DataModule and active my first PgSQLMonitor.
My question now is:
Why when I did set my PgQuery to active=true in design time I could see dbMonitor traces and not in runtime ?
I hope this helps somebody in the future.
 
			
					
				
				Posted: Thu  04 Nov 2010 09:15
				by AlexP
				Hello,
Please create a small project to demonstrate the problem, because I can not reproduce it. I can see a trace in dbMonitor both in the run-time and in the design-time mode.
			 
			
					
				
				Posted: Sun  07 Nov 2010 21:06
				by yapt
				Here you have.  I have been able to reproduce it:
I sent you 1 form and 2 datamodules.   Design and source code.
You must change:
- user/passwords
- databases
- schemas 
- table in PgQuery
After you can compile it ok, activate ONLY the PgSQLMonitor1 in Datamodule3.  Click menu: PostgreSQL->DbMonitor and run the application.
As you can see Form1.PgQuery is associated to DataModule3.PgConnection1 and DataModule3.PgSQLMonitor1 is active but if you do click on Form1.button2 (smaller button), nothing is showed in DbMonitor window in spite of the PgQuery is executed.
I hope this will be useful for you.
Greetings...
Code: Select all
//***************************************************************
//***************************************************************
//***************************************************************
//***************************************************************
//
//  form 1
//
//****** DESIGN ***********
object Form1: TForm1
  Left = 344
  Top = 185
  Caption = 'Form1'
  ClientHeight = 167
  ClientWidth = 172
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 16
    Top = 16
    Width = 148
    Height = 25
    Caption = 'Connect DM2'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Button2: TButton
    Left = 16
    Top = 64
    Width = 75
    Height = 25
    Caption = 'Button2'
    TabOrder = 1
    OnClick = Button2Click
  end
  object Button3: TButton
    Left = 16
    Top = 112
    Width = 148
    Height = 25
    Caption = 'Button3'
    TabOrder = 2
    OnClick = Button3Click
  end
  object PgQuery1: TPgQuery
    Connection = DataModule3.PgConnection1
    SQL.Strings = (
      'SELECT count(1) as c FROM schema2.atable')
    Left = 120
    Top = 56
  end
end
//
//  form 1
//
//****** SOURCE CODE ***********
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DB, MemDS, DBAccess, PgAccess;
type
  TForm1 = class(TForm)
    PgQuery1: TPgQuery;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
uses Unit2, Unit3;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
  DataModule2.PgConnection1.Connected := true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
  if Button2.Caption  'Button2' then
    PgQuery1.Active := False
  else
  begin
    PgQuery1.Active := True;
    Button2.Caption := IntToStr(PgQuery1.FieldByName('c').AsInteger);
  end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
  DataModule2.PgConnection1.Connected := false;
end;
end.
//***************************************************************
//***************************************************************
//***************************************************************
//***************************************************************
//
//  DataModule 2  (first datamodule).
//
//****** DESIGN ***********
object DataModule2: TDataModule2
  OldCreateOrder = False
  Left = 801
  Top = 188
  Height = 150
  Width = 215
  object PgConnection1: TPgConnection
    Username = 'user'
    Password = 'password'
    Server = 'localhost'
    LoginPrompt = False
    Database = 'MyDatabase'
    Schema = 'schema1'
    Left = 24
    Top = 16
  end
  object PgSQLMonitor1: TPgSQLMonitor
    Active = False
    Left = 88
    Top = 32
  end
end
//
//  DataModule 2  (first datamodule).
//
//****** SOURCE CODE ***********
unit Unit2;
interface
uses
  SysUtils, Classes, DASQLMonitor, PgSQLMonitor, DB, DBAccess, PgAccess;
type
  TDataModule2 = class(TDataModule)
    PgConnection1: TPgConnection;
    PgSQLMonitor1: TPgSQLMonitor;
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  DataModule2: TDataModule2;
implementation
{$R *.dfm}
end.
//***************************************************************
//***************************************************************
//***************************************************************
//***************************************************************
//
//  DataModule 3  (second datamodule).
//
//****** DESIGN ***********
object DataModule3: TDataModule3
  OldCreateOrder = False
  Left = 802
  Top = 338
  Height = 150
  Width = 215
  object PgSQLMonitor1: TPgSQLMonitor
    Left = 80
    Top = 40
  end
  object PgConnection1: TPgConnection
    Username = 'user'
    Password = 'password'
    Server = 'localhost'
    LoginPrompt = False
    Database = 'MyDatabase'
    Schema = 'schema2'
    Left = 24
    Top = 16
  end
end
//
//  DataModule 3  (second datamodule).
//
//****** SOURCE CODE ***********
unit Unit3;
interface
uses
  SysUtils, Classes, DB, DBAccess, PgAccess, DASQLMonitor, PgSQLMonitor;
type
  TDataModule3 = class(TDataModule)
    PgSQLMonitor1: TPgSQLMonitor;
    PgConnection1: TPgConnection;
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  DataModule3: TDataModule3;
implementation
{$R *.dfm}
end.
 
			
					
				
				Posted: Mon  08 Nov 2010 08:30
				by AlexP
				Hello,
To monitor dynamic SQL execution in the run-time mode you should create a data module with active SQLMonitor before you create your form. 
program Project1;
uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {DataModule2: TDataModule},
  Unit3 in 'Unit3.pas' {DataModule3: TDataModule};
{$R *.res}
begin
  Application.Initialize;
  Application.CreateForm(TDataModule3, DataModule3);
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TDataModule2, DataModule2);
  Application.Run;
end.
			 
			
					
				
				Posted: Mon  08 Nov 2010 11:41
				by yapt
				It is already in this way.