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?
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?
Use a Timer to periodically execute your query and update the UI.
Create a timer in your C# application that will call a stored procedure on your database to retrieve the results into a DataSet.
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.
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.
Use a Backgroundworker to retrieve data, then use a message to the GUI thread to update in the form