Page 1 of 1

EMSErrors traped in dbMonitor

Posted: Tue 20 Mar 2012 21:37
by radub
Win 7 ultimate
SDAC 4.80.0.60
Delphi 7

I have an application running on several databases.
I create a TMSSQLMonitor with [moDBMonitor] in Options.

If the trapped data comes from a component, through the component's connection I can point to what database is talking about, but when is trapping an error I can't identify from which database is coming.
Is there any possibility to retrieve the database name?

Thank you

Posted: Wed 21 Mar 2012 12:39
by AndreyZ
Hello,

We don't understand what functionality you want to get. Please specify it in details using code examples that demonstrate it.

Posted: Wed 21 Mar 2012 12:47
by radub
In OnSQL event of the TMSSQLMonitor, the Sender could be cast as specific component (TMSConnection, TCustomDADataSet, TCustomDASQL etc) and through the connection property of that component I can get the name of the database from where comes the query text and I can formatted accordingly; but if the Sender is a EMSError I can't retrieve the database name.
I was wondering if there is a possibility to do that.

Thank you

Posted: Thu 22 Mar 2012 09:28
by AndreyZ
You can use the following code:

Code: Select all

procedure TMainForm.MSSQLMonitorSQL(Sender: TObject; Text: String;
  Flag: TDATraceFlag);
var
  obj: TObject;
begin
  if Sender is EMSError then begin
    obj := EMSError(Sender).Component;
    if obj is TMSSQL then
      ShowMessage(TMSSQL(obj).Connection.Database);
  end;
end;

Posted: Thu 22 Mar 2012 14:10
by radub
Thank you, it works!
Unfortunately, this property (EMSError(Sender).Component) is not documented in help (at least not in my SDAC version).

Posted: Thu 22 Mar 2012 14:55
by AndreyZ
We will add the description of the Component property to the SDAC documentation.

Posted: Fri 23 Mar 2012 06:49
by radub
I noticed that ODAC has the same Component property on EOraError, without help on it. So, it would be welcome to update ODAC's help also; I suppose the same situation on all DACs.

Thank you.
Case can be closed.

Posted: Fri 23 Mar 2012 08:54
by AndreyZ
We will add the description of the Component property to all DAC documentations.