Cannot open user default database. Login failed for user 'ERYN\ASPNET'.

Posted on 2007-10-15
Last Modified: 2013-11-26
hi there,

please help, i would be very grateful.

i have created a website and let visual studio 2005 create the aspnetdb.mdf file.
i copied all my tables into the aspnetdb database. i deployed the website to the folder C:\Inetpub\wwwroot\ACAAS

Opening my browser and navigating to http://localhost/ACAAS/Default.aspx, i see the default page, and a few entries read from the ASPNETDB database, so reading is fine. however when actually logging in or attempting any action that requires writing to the database, the following exception occurs:

Cannot open user default database. Login failed.
Login failed for user 'ERYN\ASPNET'.

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

In no particular order i have done the following to no avail:

i gave full control to ASPNET process on the ACAAS directory in my wwwroot folder under security settings.

under control panel -> User Accounts, i have assigned ASPNET process to administrator group.

logging into SQL Server Management Studio Express using windows authentication, i have attached ASPNETDB and created a new user: aspnet, password: aspnet@123 and mapped it to all the databases like master etc including ASPNETDB.

i did the same for the sa account

i set the default database for both these accounts to ASPNETDB, (not sure if i has to, did it anyway)

My connection string residing in webconfig is as follows:

<add name="ACAAS" connectionString="Data Source=ERYN\SQLEXPRESS;Database=ASPNETDB;uid=aspnet;password=aspnet@123;Integrated Security=False;User Instance=False" providerName="System.Data.SqlClient" />

using the surface area configurator, i enabled remote connections with the tcp/ip and named pipes option. (not sure if i had to did it anyway)

using the sseutil utility i detached all database instances, except for master, etc. for those i couldn't remove i.e. sseutil -d <database path> doesn't like the 'and' in path 'Documents and Settings', i open up task manager and kill all my sqlservr, browser and writer processes.

i used the aspnet_regiis utility to register ASPNET 2.0....57 with IIS.

Express and i do not have VS2005 open.

i restart my computer after making changes and check that the processes are up and running before attempting again.

i think that's all i've done. i belong to a domain but trying on either logins makes no difference.

i'm running XP SP2, IIS with the SMTP, ASPNET 1.1 and 2.0, i got VS2003 and VS2005, SQL Server 2000 and SQL Server Management Studio Express, McAfee VirusScan Enterprise and IE7.

if you want me to run any utilities please be quite specific where i can find them and what i must do.

thank you.
Question by:Eryn-South_Africa
    LVL 12

    Assisted Solution


    Add a new login called 'ERYN\ASPNET' with windows auth.  give proper database access.
    LVL 142

    Accepted Solution

    >Cannot open user default database. Login failed.

    that error message means that the default database of the login that is used to connect is NOT mapped to the login.
    please double check the config, including if you look at the right instance, configure the correct login, and if your connection string matches.


    Author Comment

    thanks for the prompt response, looking under SSMSE, i have checked that mixed mode is enabled for ERYN\SQLEXPRESS

    i have looked under security ->logins i see user aspnet, i see that it is mapped to all databases, it appears under the ASPNETDB database users as well. (i had already added ERYN\ASPNET to users (more on this later))

    looking in my deployed webconfig i see

    i restarted ERYN\SQLEXPRESS

    using sseutil -l    i see some other databases attached... didn't do anything bout them for now...

    opened browser, ran site, same story, Question: why is it using ERYN\ASPNET? (isn't this windows authentication?), i want it to use the user: aspnet (SQL Server authentication).

    have i inadvertantly changed something i shouldn't have

    Author Comment

    do i need to grant any explicit permissions for users on the attached ASPNETDB database?
    LVL 142

    Assisted Solution

    by:Guy Hengel [angelIII / a3]
    >do i need to grant any explicit permissions for users on the attached ASPNETDB database?
    not for the login attempt itself.

    now, what is the default database configured for that login? does that database exist?

    Author Comment


    i was using ASPNETDB as the default database for user: aspnet. my coworker guessed that because it's the same as the ASPNET account it might interfere, so i changed it to aspnet1 and double checked all the defaults and mappings. everything looks ok, still this error.

    Author Comment

    my coworker also said that ERYN\ASPNET shouldn't even have a login, that there was no reason for it being on SSMSE, could he be right? since i was the one who added it with mappings.

    Author Comment

    while all your comments are absolutely correct, something is still prohibiting the ASPNET process from accessing my application.

    my sqlexpress might be configured incorrectly, so i'm going to implement the membership database using SQL2000 using scott gu's blog as a guideline.

    if this still fails, i'm going to uninstall vs2005/3, iis and ssmse, etc and try again.

    thank you for your comments

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now