Visual Studio 2017 在应用程序设置中找不到连接字符串

Visual Studio 2017 the connection string could not be found in application settings

对于连接数据库和读取数据,我使用的是从 Web.config 文件中读取连接字符串的数据集。一切都在 Visual Studio 2013 年工作。但是当我在 Visual Studio 2017 年打开这个项目时,我无法配置。错误:

Unable to find connection string xxxx. the connection string could not be found in application settings or the data provider associated with the connection string could not be loaded

首先尝试 更新 您的 Visual Studio 到 15.9。如果它没有解决问题,请尝试以下步骤:

  • 关闭 DataSet window 出现错误。
  • 右键单击解决方案资源管理器中的 DataSet
  • Select "Open with…" 来自上下文菜单。
  • Select "Source Code (Text) Editor" 并按 "OK" 按钮。

Near the top of the file, you'll see a element with several elements within it. Most DataSet should only have one element. If you are having trouble like I've described above, you'll have at least two and one will be incorrect. Delete it or otherwise fix it, save the file and reopen normally.

参考文献:

https://blog.dmbcllc.com/unable-to-find-connectionfor-object-webconfig/

Problem to update my dataSet designer : Unable to find connection 'ERMConnectionString (Settings)1'

Failed to load dataset because of the following error: Unable to find connection ...

Dataset Designer: "Unable to find connection MyConn (MySettings)1 for object 'MySettings'"

这是一个 TableAdapter 错误。 TableAdapter 提供您的应用程序和数据库之间的通信。有人声称似乎 Visual Studio 15.8.x 不再使用 web.config[=20= 中的连接字符串] 虽然您在 15.7.x.

等早期版本中可能没有任何问题

我相信您可以通过使用 How to: Save and edit connection strings.

中列出的方法之一来 重现一个有效的方法

将 VS 更新到 15.9。这将解决现有问题