当数据库表更新或插入时,如何使控件自动更新? [英] How to have control automatically update when the database table updates or inserts?

查看:117
本文介绍了当数据库表更新或插入时,如何使控件自动更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个已绑定到MySQL数据源的listView,但是我似乎无法弄清楚如何在不更改数据库表(更新/插入)的情况下如何让listView自动显示结果(没有更新)用户必须触发一个事件,例如单击按钮,计时器滴答声等...

有人能指出我正确的方向吗?任何建议/解决方案将不胜感激!

谢谢,
-Donald

I have a listView that I''ve binded to a MySQL dataSource but I can''t seem to figure out how to have the listView automatically display the results when changes are made to the database table (update/insert) without the user having to fire an event i.e. button click, timer tick, etc...

Can someone please point me in the right direction. Any advice/solutions would be greatly appreciated!

Thanks,
-Donald

推荐答案

我可能是错的,因为自从我使用MySQL已有很长时间了,但是mySQL不支持通知.查看数据库中更改的唯一方法是每隔一定间隔重新运行查询,然后将其与两个数据集之间的差异进行比较,或者...

您的数据库必须为数据库的每次更改添加时间戳.每个客户端在查询数据库时都会获得一个时间戳.下一个查询将使用该时间戳记来告诉数据库在此时间戳记后将所有更改提供给我".


哦,SQL Server确实支持通知. Google for"SQL Server通知服务".
I could be wrong as it''s been a long time since I''ve used MySQL, but mySQL does not support notifications. The only way to see a change in the database is to rerun the query at an interval and compare the differences between to the two datasets, or...

You database woujld have to timestamp each change to the database. Each client would get a timestamp when it queries the database. That timestamp is used by the next query to tell the database to "give me all the changes AFTER this timestamp".


Oh, SQL Server DOES support notifications. Google for "SQL Server Notification Service".



您可以在此处使用Sql缓存依赖项.....

1)您必须将数据存储在缓存中并提供给列表框..
2)当数据库更改缓存更新时.....
Hi,
You Can Use Sql cache dependency here .....

1)you have to store data in cache and give to list-box..
2)when database changes cache get updated.....


感谢Tushar!我不知道缓存依赖项"!我已经使用threadTimer池化数据库已有几个月了.使用缓存依赖正是我一直在寻找的东西.

再次感谢!
Thanks Tushar! I wasn''t aware of ''cache dependency''! I''ve been pooling the database with a threadTimer for months now. Using cache dependency is exactly what I''ve been looking for.

Thanks again!


这篇关于当数据库表更新或插入时,如何使控件自动更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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