views:

166

answers:

3

I've built an ASP.Net site in Visual Studio, and created the DB inside it (the .mdf file is in the APP_data folder).

Now, when I want to deploy in the customer site, I think about maintaining the DB without open Visual Studio, and by using the SQL Server Express tools (back up etc.).

I've searched how to do this, and learned that I should attach the .mdf file to sql server.

I've tried to do this and failed!

The error is: Unable to open the physical file "< .mdf >". Operating system error 5: "5(failed to retrieve text for this error. Reason: 15105)". (Microsoft SQL Server, Error: 5120)

Google didn't helped me to solve the problem.

Now I have 2 options: 1. To give up and deploy the site in the current situation where the DB is an .mdf file and ASP.Net can connect to it by the SQL server express compact (in the proccess).

  1. To extract all the data (I need to think how...) and import it to new DB, this time in SQL Server DB.

Wat would you recommend doing?

Thank you in advance.

+2  A: 

Error 5 is usually permissions related. Do you have permissions to access the file in it's location?

Mitch Wheat
+1  A: 

If on Windows Vista or higher, try opening SQL Server Management Studio by right clicking and saying "Run as Administrator". As Mitch mentioned maybe it is just a permissions issue. Then try attaching to the database.

Jason Rowe
A: 

If you've created it in Visual Studio, it's most likely an Express database. SQL Server does not support "user mode" database connections which SQL Server Express use. Despite sharing a name, they are two fairly distinctive and different technologies.

To view the contents of an SQL Express database (ie- created in Visual Studio) I just use the Visual Studio server explorer.

FerretallicA
In future if you need to manipulate data from within Visual Studio with a proper SQL Server database you can go into: "Tools -> Options -> Database Tools -> Data Connections" and change "SQLEXPRESS" to the identifier for a proper SQL Server connection (eg: "MyServer\SQL2008").
FerretallicA