C# 更新数据库源后,如何让 Visual Studio 2010 刷新我的数据集?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16967155/
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-08-10 08:15:43  来源:igfitidea点击:

How do I get Visual Studio 2010 to refresh my DataSet after I have updated the Database source?

c#databasems-accessdatasetrefresh

提问by armadadrive

I have added new columns to an existing MS Access 2010Database that I have hooked into Visual Studio 2010. After updating the Database, the Data Source window and DataSetdo not have the new columns. I looked at answers such as this: Visual Studio DataSet Designer Refresh Tables, but configuring the default query with "SELECT * FROM Reservations" (where it has been suggested that updating the query will cause the table to refresh) hasn't refreshed anything. And the built-in "Refresh" buttons on the Data Sources and Database Explorer windows haven't caught the updates yet (there is also a new table I would like to work with shortly).

我已将新列添加到MS Access 2010我已连接到的现有数据库中Visual Studio 2010。更新数据库后,数据源窗口并DataSet没有新列。我查看了这样的答案:Visual Studio DataSet Designer Refresh Tables,但是使用“SELECT * FROM Reservations”(有人建议更新查询将导致表刷新)配置默认查询并没有刷新任何内容。数据源和数据库资源管理器窗口上的内置“刷新”按钮还没有捕捉到更新(还有一个我想很快使用的新表)。

How the heck do I (non-programatically) update my DataSet? I have custom bindings and do not want to have to manually re-create those by removing this data source and 're-adding' it. I would rather add some custom bindings for my new fields and keep on working away at this project!

我到底如何(非编程)更新我的数据集?我有自定义绑定,不想通过删除此数据源并“重新添加”它来手动重新创建它们。我宁愿为我的新字段添加一些自定义绑定并继续在这个项目上工作!

采纳答案by armadadrive

Mine turns out to be close to a duplicate question... See this for the answer (and yes, it is as simple as going through the TableAdapter configuration under the DataSet designer.)

我的结果接近重复的问题......请参阅this以获得答案(是的,它就像通过DataSet设计器下的TableAdapter配置一样简单。)

Update DataSet structure in Visual Studio to match new SQL Database Structure

更新 Visual Studio 中的数据集结构以匹配新的 SQL 数据库结构

Also, see: http://msdn.microsoft.com/en-us/library/ms171902%28VS.80%29.aspx(How to edit TableAdapters)

另请参阅:http: //msdn.microsoft.com/en-us/library/ms171902%28VS.80%29.aspx(如何编辑 TableAdapter)

... and, as I figured out after nearly losing my mind, I was actually one sub-folder off (meaning there were two copies of the database in my project folder). Projects -> MyProject -> db.accdb, and Projects -> MyProject -> MyProject -> db.accdb. If you're having this issue and querying is NOT working, look VERY closely at the path. VERY CLOSELY. :)

...而且,正如我在几乎失去理智后发现的那样,我实际上是一个子文件夹(意味着我的项目文件夹中有两个数据库副本)。项目 -> MyProject -> db.accdb,以及项目 -> MyProject -> MyProject -> db.accdb。如果您遇到此问题并且查询不起作用,请仔细查看路径。很接近的。:)