views:

180

answers:

2

Hi,

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)

A: 

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.

Tahbaza
"connect to file" option - could you elaborate?
dragonfly
right click Data Connections; click the Change button at the top, right of the dialog, select Microsoft SQL Server Database File
Tahbaza
+3  A: 

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.

marc_s
Ahh, it's specyfic to Express editon. Yeah, attaching file worked fine. Thanks for explaination!
dragonfly