0

I was trying out making a website with asp.net to see how data binding works but when I launch the application, it throws this error.

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.

I checked the internet and I found a lot of possible solutions but none of them worked for me.

I created a custom database in the App_Data folder of the project and the connection string is

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Niranjan
  • 813
  • 2
  • 12
  • 33

1 Answers1

1

It cannot locate the data file at the specified path, or the user does not have sufficient privileges to access the data file.

If the database is set up for Windows Authentication Mode, you should try changing your connection string to something like this:

Server=<COMPUTER NAME>\SQLEXPRESS;Database=<DATABASE NAME>;Trusted_Connection=True;

OR

Server=<COMPUTER NAME>\SQLEXPRESS;AttachDbFilename=<DIRECTORY PATH>\<FILE NAME>.mdf;Trusted_Connection=True;
James Johnson
  • 45,496
  • 8
  • 73
  • 110
  • but I work from the user account which has admin privilege, i tried those above changes you suggested... it didn't work :( – Niranjan Aug 05 '11 at 19:45
  • sorry for the late reply... it worked later, i dunno exactly how but it worked after I changed my settings in asp .net impersonation – Niranjan Sep 12 '11 at 05:13