views:

212

answers:

3

Hi,

I hope somebody can help me out on this question.

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 would like to have the other clients to be aware of the update.

Has ony one already done this before?

Thank you very much!

Marcel

A: 
  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.

Raj
Probably. I'll update post.
Raj
@Raj. I must have just tacked that on as a question to the OP at the same time as you replied!
Martin Smith
Hello Raj,I would like the clients to be aware of any changes to the database. As stated above, notification services looks like no solution because of the update frequency during peak times (every 5 sec.).Do you maybe have some other ideas?
Marcel
Well I didn't completely read this link http://msdn.microsoft.com/en-us/library/cc998491.aspx but it says something distributed LINQ queries and subscription/filtering etc.
Raj
+1  A: 

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.

Martin Smith
A: 

Hello Martin,

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

Marcel
@Marcel - Agreed that doesn't sound particularly useful for your scenario then. By the way on Stack Overflow questions and answers are separated so you should edit this additional info into the question rather than post it as an answer!
Martin Smith
I'm sorry Martin for the wrong use... :)Do you maybe have some other ideas regarding this? Any other other options available to use instead of Service Broker notifications?Thx,Marcel
Marcel
@Marcel Not really. If you can't get push notifications then I guess you'll have to have your applications poll the database itself and compare against a timestamp or datetime field to find records that have changed.
Martin Smith