EMSErrors traped in dbMonitor

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
radub
Posts: 105
Joined: Sat 10 Jul 2010 18:46

EMSErrors traped in dbMonitor

Post by radub » Tue 20 Mar 2012 21:37

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

AndreyZ

Post by AndreyZ » Wed 21 Mar 2012 12:39

Hello,

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

radub
Posts: 105
Joined: Sat 10 Jul 2010 18:46

Post by radub » Wed 21 Mar 2012 12:47

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

AndreyZ

Post by AndreyZ » Thu 22 Mar 2012 09:28

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;

radub
Posts: 105
Joined: Sat 10 Jul 2010 18:46

Post by radub » Thu 22 Mar 2012 14:10

Thank you, it works!
Unfortunately, this property (EMSError(Sender).Component) is not documented in help (at least not in my SDAC version).

AndreyZ

Post by AndreyZ » Thu 22 Mar 2012 14:55

We will add the description of the Component property to the SDAC documentation.

radub
Posts: 105
Joined: Sat 10 Jul 2010 18:46

Post by radub » Fri 23 Mar 2012 06:49

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.

AndreyZ

Post by AndreyZ » Fri 23 Mar 2012 08:54

We will add the description of the Component property to all DAC documentations.

Post Reply