9

Is it possible to know when and if the contents of certain tables in a database has changed? How can my SQL Server notify the client applications that the data was changed by another user? How to implement query notifications with dbGo ?

Do my clients need to poll the database, or is there a callback mechanism for this?

My client is a Delphi application with TADODataSet, and my server is SQL Server 2005/2008, serving multiple clients.

TLama
  • 75,147
  • 17
  • 214
  • 392
ZigiZ
  • 2,480
  • 4
  • 25
  • 41
  • 1
    Possible duplicate http://stackoverflow.com/q/9671284/960757 – TLama May 17 '12 at 15:14
  • 1
    @TLama, still no conclusive solution for TADODataSet and SQL-Server there. – ZigiZ May 17 '12 at 15:35
  • 1
    If [`this answer`](http://stackoverflow.com/a/9671708/960757) is correct, then *dbGo (ADO) does not support notifications*... – TLama May 17 '12 at 15:47
  • 3
    This one is better http://stackoverflow.com/q/7843019/960757, however the answer is still no, dbGo doesn't support query notifications. – TLama May 17 '12 at 17:56
  • 1
    This is why I prefer to use Bold for Delphi framework. It update the clients automatically when database is changed. It is very convenient. There is of course a lot of other features also to speed up development. – Roland Bengtsson May 18 '12 at 10:13

2 Answers2

6

The Delphi dbGo controls does not support Query Notifications, so either poll the database or try to check e.g. some of the following:

Community
  • 1
  • 1
TLama
  • 75,147
  • 17
  • 214
  • 392
1

No, you would have to build your own "middle tier" to do this. The simplest way is to poll the server. A more complex solution is to build your own "middle tier" server that polls the database and pushes notifications to the clients (with your own client connection).

A middle ground solution is to have a separate client on the server poll the tables you need to "watch" and write "notfication flags" into another database table that can be polled by the clients. At least this way the clients can poll a simple table with minimal data that lists what has changed which can then be read by another select query. A lot less effort on the part of the clients.

Misha
  • 1,816
  • 1
  • 13
  • 16
  • There is also a "mixed-middle-ground" way: the record-changing database client apps themselves (including application server side logic) can send broadcast 'record changed!' messages to all listening clients over the middle tier. This would be an 'immediate' way to notify other apps about the change. In addition, your 'separate client on the server' could run in longer intervals to reduce the amount of polling, and could skip a polling cycle every time it receives a client-generated notification messages... – mjn May 18 '12 at 17:03