2

I am creating a package of an asp.net mvc3 application to distribute it. Means I want to zip it and send it to someone for review. I want that you just start the solution in VS and it runs. So no need for changes in web.config.

I was using sql server with hard-coded DataSource. (COMPUTERNAME\SQLEXPRESS) I changed it to .\SQLEXPRESS to make it relativ. Better. Then i detached the db with SSMS, copied the DB to the App_Data folder, added AttachDBFilename=|DataDirectory|MyDatabase.mdf; And (as found on msdn) Initial Catalog=; "use it but don't set it"->great feature ;)

This is the result:

<connectionStrings>
    <add name="DBService" connectionString="Data Source=.\SQLEXPRESS;AttachDBFilename=|DataDirectory|MyDataBaseFile.mdf;Initial Catalog=;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>

When I start the asp.net Development Server (hit "play") in VS Web Developer 2010 there is a Database error: Unable to open the physical file ".........mdf". Operating system error 5: "5(Zugriff verweigert)".

Any suggestions how to attach the file to the solution? What about switching to Compact Edition?

Slauma
  • 175,098
  • 59
  • 401
  • 420
LukeSolar
  • 3,795
  • 4
  • 32
  • 39

1 Answers1

1

Have you tried adding

User Instance=True

?

Data Source=.\SQLEXPRESS;AttachDbFilename="|DataDirectory|MyDataBaseFile.mdf";Integrated Security=True;User Instance=True
Damb
  • 14,410
  • 6
  • 47
  • 49
  • that did the job! And the last error "Failed to generate user instance" I solved with [this](http://stackoverflow.com/questions/281500/error-failed-to-generate-a-user-instance-of-sql-server) post – LukeSolar Mar 30 '11 at 14:03