无法使用 VS 2008 Server 资源管理器连接到 MDF 文件

发布于 2024-09-12 06:23:51 字数 361 浏览 2 评论 0原文

正如标题中提到的。另一个详细信息:

  • 文件位于我的硬盘驱动器上的 App_Data 目录中
  • 我在本地主机上安装了 Microsoft SQL Server 2005(完整版,不是 Express 版)

当我尝试使用服务器资源管理器 Microsoft SQL Server 数据库文件连接到文件时,出现错误:

建立与 SQL Server 的连接时发生网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供程序:SQL 网络接口,错误:26 - 定位指定的服务器/实例时出错)

as mentioned in title. Another details:

  • file is in on my hard drive in App_Data directory
  • I have Microsoft SQL Server 2005 on my localhost installed (full, not Express edition)

When I try to connect to file using Server explorer Microsoft SQL Server Database File I get an error:

network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

っ〆星空下的拥抱 2024-09-19 06:23:51

您不能简单地单击 MDF 文件来连接到它。如果您安装了完整的 SQL Server(如您所提到的),则需要转到 SQL Server Management Studio 并将 MDF/LDF 文件作为数据库附加到 SQL Server 中。

完成后,您可以通过指定常用的 ADO.NET 连接属性(服务器名称、数据库名称、登录 SQL Server 的凭据)来连接并使用该数据库。

从目录中将数据文件作为独立 MDF 附加的功能是 SQL Server Express 的独有功能。这在 SQL Server 的任何非 Express 版本中都可用。

You cannot simply click on a MDF file to connect to it. If you have the full SQL Server installed (as you mention), you need to go to the SQL Server Management Studio and attach the MDF/LDF file as database into your SQL Server.

Once that's done, you can connect to and use that database by specifying your usual ADO.NET connection properties (server name, database name, credentials to login in to your SQL Server).

The ability to attach a datafile as a stand-alone MDF from a directory is a SQL Server Express noly feature. This is not available in any of the non-Express editions of SQL Server.

梦年海沫深 2024-09-19 06:23:51

如果您的 MDF 文件未附加到 SQL Server,请务必使用服务器资源管理器中的“连接到文件”选项并指向您的 MDF。或者,使用 SQL Server Management Studio 将 MDF 文件附加到 SQL Server 的本地实例,然后使用 VS.net 中的普通对话框指定服务器名称和数据库名称来引用数据库。

If you have an MDF file that is not attached to a SQL Server be sure to use the "connect to file" option in the Server Explorer and point to your MDF. Alternatively attach the MDF file to your local instance of SQL Server using SQL Server Management Studio and then reference the database using the normal dialog in VS.net specifying Servername and Databasename.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文