从Access数据库使用计时器轮询数据 [英] Polling Data with Timer from Access Database

查看:164
本文介绍了从Access数据库使用计时器轮询数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有这个用c#4.0构建的应用程序。它连接到一个访问数据库并从表[ABC]中获取,填充一个列表框并执行一些计算并将结果转储到exel文件。但我想知道是否有办法每隔10分钟或5分钟实时完成,而不必进行任何按钮点击事件?我对任何想法持开放态度,我不仅仅知道如何通过它自己完成所有这些操作。

谢谢。

Hi guys,I have this application I built with c# 4.0 .It connects to an access database and grab from table [ABC], populates a listbox and performs
some calculations and dumps the result in exel file .But I was wondering if there is way to do it every ten minutes or 5 minutes on a real time without me having to do any button click event? I am open to any idea, I don't just know how to get it going by its self doing all those actions.
Thanks.

推荐答案

请看我过去的答案,我建议使用我的模式,非常可靠的一个:带计时器的轮询数据库 [ ^ ]。



另外,对于某些背景,不一定非常相关,只需要理解:网站帐户的应用程序'仪表板 [ ^ ]。



-SA
Please see my past answer where I suggested to use my pattern, very reliable one: Polling Database with Timer[^].

See also, for some background, not necessarily very relevant, just good to understand: Application 'dashboard' for website accounts[^].

—SA


设置BackgroundW orker并在那里做工作。然后使用进度报告机制通过事件将新值传递给UI线程,并从中加载Listbox(如果您确实需要列表框)。然后线程一直睡到下一次,然后回到原点。



但这不是一个好方法 - 访问并不擅长多用户支持时间。如果可以,请使用SQL数据库,如果仅处理新记录或更改记录,请设置SQL触发器以启动重新计算而不是计时器: https://msdn.microsoft.com/en-us/library/938d9dz2.aspx [ ^ ]
Set up a BackgroundWorker and do the work in there. Then use the progress reporting mechanism to pass the new values to the UI thread via the event, and load the Listbox from that (if you really need the listbox). The thread then sleeps until the next time, and goes back round.

But it's not a nice way to do it - Access is not good at multiuser support at the best of times. If you can, use an SQL database, and if you are processing new or changed records only, set up an SQL Trigger to kick off the re-calculation instead of a timer: https://msdn.microsoft.com/en-us/library/938d9dz2.aspx[^]


这篇关于从Access数据库使用计时器轮询数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆