开发者

Cannot connect to MDF file using VS 2008 Server explorer

开发者 https://www.devze.com 2023-01-09 12:15 出处:网络
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)

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 in开发者_如何学编程stance-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)


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消