Cannot open user default database

Rate It (1)

Last post 07-04-2008 9:42 AM by Som Nath Shukla. 23 replies.

Sort Posts:

  • Cannot open user default database

    11-21-2005, 2:44 PM
    • Loading...
    • spotsrocks
    • Joined on 11-21-2005, 7:40 PM
    • Newark, DE (USA)
    • Posts 1
    I'm sorry if this question has already been anwered, but I couldn't find it in previous threads.  Anyway, I installed the Personal Site Starter Kit and SQL Server Express (both are local).  I then created a user for myself, and then I receive the following error when I log into the site:

     System.Data.SqlClient.SqlException: Cannot open user default database. Login failed.
    Login failed for user 'MARS\ASPNET'

     Apparently, SQL Server Express doesn't like my local ASPNET account.  Does anyone know either how to fix this or where I can go to troubleshoot this problem?

    Thanks in advance,
    Rob
  • Re: Cannot open user default database

    12-18-2005, 10:52 PM
    • Loading...
    • Norashlea
    • Joined on 12-19-2005, 3:07 AM
    • Posts 1

    Rob, did you figure out how to resolve this?

    Having the same problem and have spent 2 frustrating days trying to figure it out. Project runs from within VS.net OK -- because VS is authenticating as [machine]\ASPNET -- but if I try to run as http://localhost/[application] I just get the "Cannot open user default database..." error. I've created a [machine]\ASPNET user account in SQL Server Express, assigned it to sysadmin role, have set SQL Express to run in mixed-mode, but all to no avail.

    Sharon.


     

  • Re: Cannot open user default database

    01-08-2006, 10:45 AM
    • Loading...
    • rhythmluvr
    • Joined on 01-02-2006, 8:40 PM
    • Lugoff, SC
    • Posts 8

    Hi, I am just now making the transition from classic ASP to ASP.Net, I must say getting off the ground and running has been an extreme challenge. The help of these forums are great but all of a sudden I am now getting the same message;

    System.Data.SqlClient.SqlException: Cannot open user default database. Login failed.
    Login failed for user 'SERVER\ASPNET'

    Have you figured this out yet? If I do I will let you know.

     

  • Re: Cannot open user default database

    01-08-2006, 6:44 PM
    • Loading...
    • smcgroarty
    • Joined on 12-14-2005, 12:20 AM
    • Los Angeles Ca
    • Posts 36

    Verify the SQL connection string in the web.config file. Are you able to connect to the SQL server that is specified there?

    You might need Microsoft SQL Server Management Studio Express avalible at http://www.microsoft.com/downloads/details.aspx?FamilyID=82afbd59-57a4-455e-a2d6-1d4c98d40f6e&DisplayLang=en

     

    --Stephen
    http://velcrohurts.com
  • Re: Cannot open user default database

    01-09-2006, 11:04 AM
    • Loading...
    • rhythmluvr
    • Joined on 01-02-2006, 8:40 PM
    • Lugoff, SC
    • Posts 8

    I was able to fix the problem by setting up user impersonation in the asp.net configuration. I don't know enough yet to know if this is a good thing or not. Is it OK, security wise to allow this setting? Also here is my connection string from my web.config file.

    <connectionStrings>

    <add name="dbConnection" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ITNetworkSC.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />

    </connectionStrings>

  • Re: Cannot open user default database

    01-23-2006, 4:21 PM
    • Loading...
    • fatmidget
    • Joined on 01-23-2006, 9:17 PM
    • Posts 1

    I had the same use and tried a whole bunch of things, but this is what solved it for me:

    - it seems I had the DB still opened inside my IDE (Visual Web Developer Express), in the database explorer. Right-clicking the database and selecting "close connection" fixed it.

    Hope this helps.

  • Re: Cannot open user default database

    02-06-2006, 11:47 AM
    • Loading...
    • SPINFX
    • Joined on 02-06-2006, 4:38 PM
    • Posts 1

    I have had the same problem and it is really getting frustrating after spending a whole weekend trying to figure it out.  Here is what I have done and it's really not a good thing to do, but nothing else works:

    I am running Windows XP Pro SP 2 with VS 2005 and SQL Express.  I can run the site fine through VS, but when I Publish it to a different folder that my IIS Website is pointing to, I get the same error message when I pull it up in a browser.  I am not connected to a domain, but have the machine setup as a workgroup.  The ASPNET id needs access to the folder where the database files are stored.  Since I am running the machine as a workgroup, I can't give specific permissions to each user.  I put the MACHINENAME\ASPNET user in the admin group on the machine.  I know this is a terrible idea because of security, but it's the only way it will work for me.  I think there is some kind of bug in SQL Express and using it under a workgroup instead of a domain, but nobody has actually figured this one out yet.  Hope this helps.  Let me know how it goes or if you've come up with another solution.

  • Re: Cannot open user default database

    02-06-2006, 9:49 PM
    • Loading...
    • rhythmluvr
    • Joined on 01-02-2006, 8:40 PM
    • Lugoff, SC
    • Posts 8

    A couple of things you might want to consider in your environment.

    You can get the security tab to work in Windows XP Professional that is installed in a workgroup by changing the following registry key

    Registry Key and Values

    When security settings are set in Windows XP, the following registry key is used:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa

    The values are:

    ForceGuest=1: Use this value to force guests on
    ForceGuest=0: Use this value to force guests off

     Changing the value to 0 will give you the security tab in your folders, file properties window.

    Also I have noticed sometimes that programs may write to the windows\temp directory, the asp.net user may need rights to this folder on the server machine only. Of course this may not be your case.

    Anyway I hope this helps with assigning the user rights in Windows XP Professional.

     

  • Re: Cannot open user default database

    02-27-2006, 4:39 PM
    • Loading...
    • nietoperz82
    • Joined on 02-27-2006, 9:33 PM
    • Posts 1
    Hi

    I do something that:
    Download and install SQL Server Managment Studio Express
    http://www.microsoft.com/downloads/details.aspx?FamilyID=82afbd59-57a4-455e-a2d6-1d4c98d40f6e&DisplayLang=en

    After that I set authentication in SQLServer (use SQL Server Managment Studio Express) to SQL Server and Windows mode and add user localhost\aspnet from Windows and I allow connect them  and this work.

    I hope I help.

    Nietoperz (bat)

    Sorry for my bad English:)
  • Re: Cannot open user default database

    04-03-2006, 4:16 PM
    • Loading...
    • eladros
    • Joined on 12-12-2002, 4:41 PM
    • Posts 25
    fatmidget

    , u r a life saver.This is also solved the problem

    10x !

  • Corrupted database

    08-29-2006, 8:55 AM
    • Loading...
    • Petrander
    • Joined on 10-31-2005, 3:13 PM
    • Copenhagen
    • Posts 122
    I had the same problem using VWD, but it was caused by a corrupted database file. I didn't need it, so I went in database explorer, right-clicked and deleted it. After that, the problem was gone...
  • Re: Cannot open user default database

    12-28-2006, 12:50 PM
    • Loading...
    • monishjain
    • Joined on 12-28-2006, 5:28 PM
    • Posts 1

    Hi,

    I recently stumbled on this problem. After 10 hours of trying various options, I could isolate the solution to this issue.

    Configuration:

    Windows XP Professional, SQL Server 2005, SQL Server Express 2005, Visual Studio .Net 2005, Visual Web Developer.

    Solution: 

    Initially, I added 'machinename/ASPNET' as user to SQL Server Express database engine. I also added it as a user to my application database.  However, it did not work. Utlimately I removed 'machinename/ASPNET 'user from database engine as well as application database.

    I checked the user ASPNET alongwith the Groups it belonged to. And there was the problem.

    So I added ASPNET as a member of SQLServer2005MSSQLUser$server$SQLExpress. And it worked. I could reproduce the issue by removing it from the group again.

    Steps (Windows XP):

    Go to Control Panel -> Administrative Tools -> Computer Management -> Local Users and Groups -> Users -> ASPNET

    Right Click on ASPNET and select Properties

    Go to Member Of tab.

    Click on Add -> Advanced -> Find Now

    Select SQLServer2005MSSQLUser$<machinename>$SQLExpress

    Click on Ok -> Ok - >Apply

    Close all the windows and reboot your machine. It should work now.

     

     

     

  • Re: Cannot open user default database

    03-15-2007, 7:46 AM
    • Loading...
    • dahlheim
    • Joined on 03-15-2007, 11:45 AM
    • Posts 1
    OMG THANK YOU monishjain, this one was really annoying to try to solve.  your solution worked.
  • Re: Cannot open user default database

    06-05-2007, 5:20 PM
    • Loading...
    • Ishtanzar
    • Joined on 09-24-2006, 12:18 PM
    • Posts 2

    Thanks a lot !!!

    Working out on a student project, I set the User Instance to false for a connection and for no reason my ASP.NET website could no longer use any mdf file nor connect to my SQL Server Express at runtime Crying

    After hours, I've just read your post and tried and it works !! You've saved my life Cool

  • Re: Cannot open user default database

    07-09-2007, 10:59 AM
    • Loading...
    • gogginl
    • Joined on 06-29-2006, 5:49 PM
    • Posts 98

     

    I ran into the same problem was unable to select Security option within ASP.NET web admin tool which prompted that the default database or username was incorrect. Within the VS I selected Tools, Connect to Database, and right click on ASPNETDB.MDF and selected "Close connection" following this I was able to rerun ASPNET configuration from VS and this time allowed me to logon and access the roles etc...
Page 1 of 2 (24 items) 1 2 Next >