Sql-server – Cannot access local database with IIS Manager

databaseiissql server

I've created a local .mdf database with Visual Studio 2010 and did a couple of modifications to it. Now I want to edit it in IIS Manager. However, I cannot access it neither by connection string, nor by direct specification.

First. I copied a connection string from Visual Studio 2010 properties window for the DB, it was like Data Source=.\SQLEXPRESS;AttachDbFilename=o:\...\MyDB.mdf;Integrated Security=True;User Instance=True. I went to IIS Manager -> Connection Strings -> Add -> Custom and pasted it. Then went to IIS Manager -> Database Manager -> MyDB, it opened, but there were no visible contents while I've added several tables.

Second. I used "Add Connection" in Database Manager and specified properties like following:

  • Database provider == SQL Server 2008
  • Server == localhost
  • Database == o:…\MyDB.mdf
  • User ID == my_local_user_name

But when I accessed newly created connection, I got the following error:

There was an error while performing this operation. Details:

A 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: Named
Pipes Provider, error: 40 – Could not open a connection to SQL Server)

Same if I set Server field to SQLEXPRESS. Any ideas?

  • Windows 7 x64 Ultimate
  • Microsoft SQL Server 2008 x64
  • Visual Studio 2010 Professional SP1
  • IIS Manager x64

Best Answer

Don't use the AttachDbFileName syntax of the connection string. Just attach the database to the SQL Server instance and log into the instance as normal. Once you get your app out to the hosting provider they aren't going to let you use this syntax anyway as the SQL Server will probably be sitting on another server.

Are you able to make a connection to the local SQL Server instance?