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?
Have you tried adding
User Instance=True
?
Data Source=.\SQLEXPRESS;AttachDbFilename="|DataDirectory|MyDataBaseFile.mdf";Integrated Security=True;User Instance=True
精彩评论