数据插入SQL数据库表时填充datagridview [英] Fill datagridview when Data insert into SQL Database Table

查看:102
本文介绍了数据插入SQL数据库表时填充datagridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发包含datagridView的Windows应用程序。当数据插入MS SQL数据库,然后我想将它显示到DataGridView。现在我正在使用Timer哪个Ping数据库(打开数据库连接,执行查询,如果找到数据然后更改DataGridView的数据源)。是数据插入表中时运行的另一种方法(无需Ping数据库)我可以使用Windows服务

I am Developing Windows Application Which Contain datagridView. when data is inserted into MS SQL Database then i want to display it into DataGridView. Now I am Using Timer which Ping Database (Open DB Connection,Execute Query,if data Found then Change datasource of DataGridView). is Any Another Method which Run when Data inserted into Table(No Need To Ping DB) Can I Use Windows Services

推荐答案

而不是使用计时器构造某些东西使用观察者模式(也称为发布/订阅)



这篇CP文章是一个很好的起点使用SqlDependency进行数据更改事件 [ ^ ]但还有其他人(现在您知道要搜索Observer或Publish Subscribe它应该更容易找东西)
Rather than using a timer construct some thing using the Observer pattern (also known as publish/subscribe)

This CP article is a good starting point Using SqlDependency for data change events[^] but there are others (now that you know to search for "Observer" or "Publish Subscribe" it should be easier to find something)


这篇关于数据插入SQL数据库表时填充datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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