Knowledgebase: MSSQL
How to fix: Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path.
Posted by on 31 March 2011 06:21 PM

If you are receiving the following error:

System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.


It means you are either trying to connect an mdf file to the SQL server or are in another way trying to create your own instance of SQL server. In a shared environment, it is not possible to do this. To use that database file, you will need to make a backup of it in a .bak format. Then, from your control panel:

1) Make a database:
2) Restore the .bak file into the database:
3) Change your connection string to appropriately use the SQL server instance on your server:

(6 vote(s))
Not helpful

Comments (2)
Jeremy Collins
01 June 2011 08:51 PM
I am receiving this error, but I am not trying to connect an mdf file. At first I wasn't sure how to create the membership tables, but I eventually found the article that shows how to use aspnet_regsql.exe. I had already created a DB for my website, so I went ahead and added the membership tables to that with no problem. In addition, I'm using the appropriate connection string:

<add name="ConnectionString1" connectionString="Data Source=localhost\sqlexpress;Initial Catalog=MyDB;Integrated Security=false;User ID=MyUserId;Password=MyPW" />

For the membership provider I'm using the same connection string:

<clear />
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

What's strange is that I was able to use my User SignUp functionality to create a user and I can see that user in the Membership and the User tables but I STILL get this error whenever I try to login with this user.

Any thoughts?
Arvand Sabetian
02 June 2011 11:06 PM
I've almost always seen this error connect to a portion of your code trying to create its own MSSQL database within a file in your file space (AppData usually). I would look throughly through libraries/code you are using to make sure this is not the fact.
Post a new comment
Full Name:
CAPTCHA Verification 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).