I\'m trying to connect to an MDF. I\'ve even gone to the lengths of re-installing sql server express entirely (it is now the only flavor of SQL installed on my box, where p
I experienced the same error when i moved the code from one machine to another. i am using VS2010 and SQLEXPRESS 2008 comes along with it.
Trick , deleting all the contents from the following folde "C:\Users\UserName\AppData\Local\Microsoft\Microsoft SQL Server Data\SQLEXPRESS" worked for me.
I started getting this error this morning in a test deployment environment. I was using SQL Server Express 2008 and the error I was getting was
"Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed."
Unsure about what caused it, I followed the instructions in this post and in other post about deleting the "C:\Users\UserName\AppData\Local\Microsoft\Microsoft SQL Server Data\SQLEXPRESS" directory, but to no avail.
What did the trick for me was to change the connection string from
"Data Source=.\SQLExpress;Initial Catalog=DBFilePath;Integrated Security=SSPI;MultipleActiveResultSets=true"
to
"Data Source=.\SQLExpress;Initial Catalog=DBName;Integrated Security=SSPI;MultipleActiveResultSets=true"
ok, it works now! guess it was a compound problem ... the steps I took to resolve it are as such:
AttachDbFilename=|DataDirectory|CustomerDb.mdf;
c:\Users\<user name>\AppData\Local\Microsoft\Microsoft SQL Server Data\SQLEXPRESS
. I thought I had looked for this before, but I had actually looked in the Microsoft Sql Server
folder. Again, a subtle difference.Once I did these two things, the connection started working :-D
Just go to web.config file. Change in 'Connection String'="....../.../......?.......; User Instance=True'" to "....../.../......?.......; User Instance=False'"
Yes this may cause some security issues, but for some school/college practical-project(Which was my case) this can run your project.
change from User Instance=True to User Instance=False , in web.config
To fix this, please Open the SQL Server Management Studio Express. In the query editor type this text:
sp_configure 'user instances enabled', 1;
RECONFIGURE
Run it. Then restart the SQL Server database.
In addition to the other solutions here, this one may also be helpful. Ensure the Application Pool is running as network service, and not ApplicationPoolIdentity.
This solution was found here: http://blogs.msdn.com/b/webdevelopertips/archive/2010/05/06/tip-106-did-you-know-how-to-create-the-aspnetdb-mdf-file.aspx