开发者

Retrieve data from database every few seconds?

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?


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.


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


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


You should use Timer.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜