Reputation: 53
I am creating a Windows form application in C# which gets a set of links from a remote Sql Server db and adds the links to a local text file. Now what I want to do is create an auto-update functionality so that every time a new link is added to the remote db, the app automatically picks it up and adds it to the text file or atleast alerts the user that there is an update.
What would be the best way to go about this?
Upvotes: 1
Views: 216
Reputation: 21188
You could start a timer on a different thread
in window application and keep checking for db update, at the same time you could do your other activity on an application.
To save db hit again and again, you could do is create a trigger
that on updation creates an xml
or any text file on your disk and then thread that starts along with the application could attempt to read that file.
I hope there would be some other good way also. Please let us know also over here in case you gets some better way.
Upvotes: 0
Reputation: 65867
You could use Timer to check the db in periodic intervals,
Or if you are using MS SQL 2000, 2005, you can implement SQL server notification services
Note: notification services not supported in SQL server 2008
Upvotes: 0
Reputation: 129792
If the database is remote you need to manually poll the database for changes at a given interval.
If the client is running on the same machine as the database, you could have a database trigger that talks to the client some way.
I guess an alternative thing you could do would be to set it up so that each client is also a server, that accepts calls from the SQL server. Then you could still set an update trigger, that issues a command to all connected client-servers. That might be a whole lot of work for a small gain, tho.
Upvotes: 1