Can the SqlDataAdapter refresh itself when the table is changed from an outside source?

泪湿孤枕 提交于 2019-12-11 06:05:50

问题


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).

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


回答1:


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



来源:https://stackoverflow.com/questions/2722744/can-the-sqldataadapter-refresh-itself-when-the-table-is-changed-from-an-outside

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!