能否SqlDataAdapter的刷新自己当表被从外源改变? [英] Can the SqlDataAdapter refresh itself when the table is changed from an outside source?

查看:203
本文介绍了能否SqlDataAdapter的刷新自己当表被从外源改变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的SQL Server表是从我的程序以外的更新(从SQL触发器,实际上),所以数据集并没有意识到有变化,我的DataGrid不更新,除非我明确地调用SqlDataAdapter.Fill()试(例如使用刷新按钮或定时事件)。

My SQL Server table is updated from outside of my program (from a SQL trigger, actually), so the DataSet doesn't realize that there are changes and my DataGrid doesn't update unless I explicitly call SqlDataAdapter.Fill() again (e.g. with a "Refresh" button or a timed event).

有没有一种方式,ADO.NET可以订阅,以便它刷新自己改变事件或这样?

Is there a way that ADO.NET can subscribe to change events or such so that it refreshes itself?

推荐答案

是的,使用的查询通知。你得到一个回调时的数据集已发生变化,再次运行查询。

Yes, using Query Notifications. You get a callback when the dataset has changed and you run your query again.

这篇关于能否SqlDataAdapter的刷新自己当表被从外源改变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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