开发者

Real time SQL database updates between multiple VB.NET clients

I'm using a SQL database and I'm writing a VB.NET client application. This application is used on multiple computers at the same time. If one of the clients makes an update to the database I wou开发者_如何学Pythonld like to have the other clients to be aware of the update.


If you are using MS SQL Server you could perhaps use Service Broker notifications to push a notification to the clients when the data gets updated. This is not something I have personal experience of using though.


  1. Ensure that your table has a DateUpdated column
  2. When reading the table save the dateUpdated value into a memory variable
  3. When updating the table include DateUpdated <=
  4. Check the number of rows updated in step 3.
  5. If step 4 returns 0 it means somebody else updated the tale while the current user was looking at the data.

Note that this is only applicable if you're interested in detecting updates when you're saving the data. If you'd want the client applicatiob to be notified if the record currently displayed has been updated then, as somebody else mentioned, you'll have to use some kind of notification services.


After looking around I found some good information about Service Broker. I also read the following;

"Query Notification is designed for data that does not change frequently. It is also best used in server-side applications (such as ASP.NET or remoting) rather than client-side applications (such as a Windows Forms application). Remember that each request for a notification is registered in SQL Server. If you have masses of client applications each requesting a notification, this can create a resource problem on your server. Microsoft's recommendation is that for client-side applications, you limit your use of query notification to not more than ten concurrent users."

This is my concern, because I have about 10 tables which are updated pretty frequeuntly (every 5 sec.).

Maybee somebody has experience with using Service Broker notifications for more frequently changing data.

Thank you very much!

Marcel


I have the same issue. My solution was to create a audit table! The audit table contain all table name and another column with date time.

When user change data, is also update the datetime in audit table.

All user check every 4 seconds the audit table. If one of the table was updated, the user reload the entire table how was updated.

Sorry for my english.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜