Mohammed Rabee
Mohammed Rabee

Reputation: 355

How to monitor SQL server database table from delphi application

How can I monitor specific table from Delphi application (real time) and get new and updated records data ?

Upvotes: 6

Views: 3883

Answers (2)

da-soft
da-soft

Reputation: 7750

In general, you can use database events / notifications / alerts. The exact term and implementation depends on a DBMS. For details you can check "DBMS alert mechanisms" at AnyDAC documentation.

On a backend you may need to implement triggers for required tables. For some DBMS it is not required. For example, with Firebird a trigger has to call POST_EVENT statement. With SQL Server the special set of Query Update Notification API operators must be called to prepare a table.

On a client you should use either special API, either standard SQL query mechanism. For example, with Firebird the special event API must be used. With Oracle a background thread + standard SQL API.

The Delphi implementation depends on a DBMS and data access components. Some examples:

  • dbGo (ADO) does not support notifications, when they are implemented using special API;
  • dbExpress - the same;
  • IBX - use TIBEvents with Firebird;
  • AnyDAC - use TADEventAlerter. It supports many different mechanisms for many DBMS in a unified way. Disclosure: AnyDAC is the flagship product of the company I represent.

Upvotes: 8

Yahia
Yahia

Reputation: 70369

SQL Server 2005 and up has a notification mechanism... but I don't know of any free component supporting this mechanism...

IF a commercial component is an option Devart SDAC supports this.

The only other option I see would be to poll (perhaps from a background thread) - but polling is usually something you want to avoid IMO.

Upvotes: 1

Related Questions