vb.net 刷新数据表的内容以从数据库中获取新数据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15333794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 12:43:27  来源:igfitidea点击:

Refreshing the content of the datatable to get new data from database

vb.netdatatabledataset

提问by IT researcher

I want to know how this can be done? I am taking data from the database and through DataAdapter i am updating values in datatable.So now if any new data are entered into database how can i refresh or update the new data to the datatable?

我想知道如何做到这一点?我正在从数据库中获取数据并通过 DataAdapter 我正在更新数据表中的值。所以现在如果有任何新数据输入数据库,我如何刷新或更新新数据到数据表?

回答by Tim Schmelter

The easiest way it to fill the DataTable/DataSetagain. A DataTableis an offline, in-memory representation of your data, so it does not know when the underlying data has changed.

再次填充DataTable/的最简单方法DataSet。ADataTable是数据的离线内存表示,因此它不知道基础数据何时发生更改。

However, you can use the SqlDependency-class. Have a look here.

但是,您可以使用SqlDependency-class。看看这里