Common SqlException (0x80131904) login error, did known fixes still doesn't work

Last post 05-30-2008 6:50 AM by blazingbiz. 2 replies.

Sort Posts:

  • Common SqlException (0x80131904) login error, did known fixes still doesn't work

    04-24-2008, 1:33 PM
    • Loading...
    • blazingbiz
    • Joined on 04-24-2008, 1:15 PM
    • Posts 4

    Hi,

    I'm Developing ASP.Net 2.0 applications on an XP Pro computer running IIS 5.1 and Visual Web Developer Express Edition with SQL Sever Express Edition. All the latest service packs and updates installed.

    I'm also using SQL Management Studio Express Edition to Manage my databases on my local SQL Express instance.

    I have to test my applications on IIS and not the VWD server, also I don't use the database in the local App_Data folder I just create them in a central and separate folder on my computer and attach them to my SQL server Express instance with Management Studio Express and use it from there.

    I create my web sites in VWD as Local IIS web sites using virtual directories with the files being stored in their regular place under My Documents/Visual Studio 2005/WebSites

    Working this way, when I want to test a page I just click on the Start Debugging button up on the VWD toolbar and the page should open up in IIS and I can test and debug from there.

    But lately I've been get this very common error:

    [SqlException (0x80131904): Cannot open database "DatabaseName.mdf" requested by the login. The login failed.
    Login failed for user 'Machinename\ASPNET'.]

    In Management Studio Express all of these settings (which should have it work) are set:

    Under the local SQL Express server instance node/Security/Logins - Machinename\ASPNET is listed with Grant and Enabled set as the Status and public and sysadmin set as the server roles

    Under the Attached database node/Security/Users - Machinename\ASPNET is listed with the db_owner role

    Also the NTFS permissions on the file system folder that has the database files in them have the Machinename\ASPNET user account with Modify, Read, Write Permissions

    The web config connection string being used is as follows:

    <add name="DatabaseConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=DatabaseName.mdf;Integrated Security=SSPI;User Instance=True"

    providerName="System.Data.SqlClient"/>


    If anyone can help me out with this I'd appreciate it.

    Thanks

  • Re: Common SqlException (0x80131904) login error, did known fixes still doesn't work

    04-30-2008, 1:21 AM
    Answer

    blazingbiz:
    I don't use the database in the local App_Data folder I just create them in a central and separate folder on my computer and attach them to my SQL server Express instance with Management Studio Express and use it from there.
     

    blazingbiz:
    <add name="DatabaseConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=DatabaseName.mdf;Integrated Security=SSPI;User Instance=True"

    providerName="System.Data.SqlClient"/>
     

    Hi blazingbiz,

    Instead of the “DatabaseName.mdf”, the database name in connection string should be “DatabaseName”. In addition, since the database is not in the “App_Data” folder and it has been attached to the SQL Server Express instance, we don't need “User Instance”. So, please change the connection string:

    <add name="DatabaseConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=DatabaseName;Integrated Security=SSPI" providerName="System.Data.SqlClient"/>

     

    Sincerely,
    Benson Yu
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
  • Re: Common SqlException (0x80131904) login error, did known fixes still doesn't work

    05-30-2008, 6:50 AM
    • Loading...
    • blazingbiz
    • Joined on 04-24-2008, 1:15 PM
    • Posts 4

    Yes, thank you that is the answer and that will solve many test server SQL login and connect issues, simplely use the Management Studio with the correct connection string as listed above.

Page 1 of 1 (3 items)
Microsoft Communities
Page view counter