tags:

views:

82

answers:

6

i need to retrieve data from database every few seconds, display them.

i use C#. When i press one button, the data should be retrieved every few seconds,the data is then displayed in a form, any idea how to do it?

A: 

Use a Timer to periodically execute your query and update the UI.

Justin Niessner
A: 

You should use Timer.

sashaeve
+4  A: 

Create a timer in your C# application that will call a stored procedure on your database to retrieve the results into a DataSet.

Ardman
A: 

I assume this is a windows forms application? If so, what you could do is add a timer to the form with a tick time of X seconds, each time it elapses you can query and update the display with the new records.

To start the process you simply start the timer.

Mitchel Sellers
+3  A: 

If you are going to do this, please.. please read this:

Walkthrough: Adding a Local Database Cache to an N-Tier Application

As others have mentioned, you can use a Timer for this. Remember that you Only want to ask the database for new data when there actually is new data to fetch.

Filip Ekberg
A: 

Use a Backgroundworker to retrieve data, then use a message to the GUI thread to update in the form

PoweRoy
BackgroundWorker is not needed in this case. It's used for long calculations or tasks, anyway you need to implement timing functionality.
sashaeve
Yes, I see according to other posts :) Didn't know you could simple update a dataset so the GUI will automaticly update. Good to know :)
PoweRoy