Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have my own virtual server and I am looking to deploy a website to it.

The problem I am having is setting up the database. Normally on a hosted site I just upload the mdf file and I get a connection string from them.

I tried attaching the mdf file that I created with VS2010 using Management Studio to the 'local' server on my virtual server.

It creates it with a name that is the path to the file 'c:\inetpub\wwwroot...'

How do I get the connection string I need for to use this in my web config file?

I guess I will need to also create a user login for this also?

I did try and just have it use the express connection string but I get this error Unable to open the physical file "C:\inetpub\wwwroot\gtro\App_Data\ASPNETDB.MDF". Operating system error 5: "5(failed to retrieve text for this error. Reason: 15105)". An attempt to attach an auto-named database for file C:\inetpub\wwwroot\gtro\App_Data\ASPNETDB.MDF failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

I have changed the app pools in IIS7 to use Network service in Identity.

There is definitely no database already attached with the same name either.

share|improve this question

Please create Database on Server. Backup local database and upload .bak file on server. Restore backup using SQL management studio.

if you don't have SQL Express Installed on your VPS. You can download and install it from Microsoft Website.

Please check following URL :

share|improve this answer
That never worked. Complains that the backup is from a different database. – ddd Dec 6 '10 at 16:07
OK, Have you checked like While restoring database you can give name of database. You can give different name and it will restore it. Please check following URL – maniargaurav Dec 7 '10 at 17:13

Since the new database has a different schema, when you restore the database you will need to visit the Options tab and choose Overwrite the existing database.

share|improve this answer

System Error 5 is Access Denied. Are you using SQL 2005 or above? When you create a database and then detach it to attach it to another server its permissions are changed so only the same account can use it. I believe the simple fix is to change the permissions on the local copy of the file to allow admins full control. More info at this blog

edit: blog is now dead.

Hope that helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.