1

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?

1
  • Will your window form remain live forever. Or will it be executed whenever user comes to system. Commented Jul 16, 2010 at 10:20

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

How would you get a trigger to "talk" to the client?
Thanks David. If I have the app poll the database - what would the best way to identify changes on the remote db? Suppose I add a new entry to the db, how could I design the app so that it knows a new entry has been made? Perhaps keep a "record count" in a local file and compare against that?
@pm_2: well the trigger could run a batch script that executes a program, that does whatever, to interact with the client
@Hastings: well yes, a record count would do, or an ID of the latest entry, and you could tuck that away in a static variable. if you need it to be persistent across closing and re-starting the application, you might want to look at the Settings file: msdn.microsoft.com/en-us/library/aa730869(VS.80).aspx If you go for the polling option, that's the kind of work that should be delegated to a backgruond thread, as Shantanu Gupta points out.
0

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

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.