SA Developer .NET

Welcome to SA Developer .NET Sign in | Join | Help
in Search

Login failed

Last post 08-16-2008, 21:26 by WhoKnowsWhat. 4 replies.
Sort Posts: Previous Next
  •  08-02-2008, 16:45 13847

    Login failed

    Good day all,

    I get the following error when I want to test an ASP project using Visual Studio .NET 2003, and SQL Server 2000.

             Cannot open database "###" requested by the login. The login failed. Login failed for user '???\ASPNET'

    I can't seem to find the cause of the problem, and I know it's something simple...Embarrassed

    Could anyone please give me clear instuctions how to fix this irritating error? Gift

    Thans a lot!!

  •  08-02-2008, 19:46 13848 in reply to 13847

    Re: Login failed

    In SQL Server you can set authentication to work with SQL authentication only, or both Windows and SQL authentication. Whatever your'e doing (or not doing) is causing the following to happen: SQL is opting for Windows authentication and the Windows user 'knocking on the door' is the ASPNET user under which .Net sites are executed by default. Depending on what you're trying to achieve, there may be more than one solution to your problem:

    If you want to use Windows authentication, make sure that anonymous access is turned off for the site in IIS. Also set the <identity impersonate="true" /> in your web.config file. (This is a nice article http://www.aspdev.org/articles/web.config/ to assist with that). The credentials of the person, using the web site will then be passed to SQL Server.

    Alternatively you could grant the ASPNET user access in SQL Server, but there's a lot of other people besides me who would be able to tell you why that is generally not a good idea. Smile

    If you want to use SQL Server authentication, you need to create a login on the server, that has access to the database "###" and then use that login in your connectionstring.

    Hope this helps. 

     

     


     

     

  •  08-03-2008, 21:15 13857 in reply to 13848

    Re: Login failed

    Thanx Johanv.

    Let me explain something else here:

    In my ASP.Net project's Server Explorer I've noticed under the Servers node that there is a SQL Servers node where there are 2 servers: SERVERNAME, and SERVERNAME\SQLEXPRESS (The database I'm using in my project is in the latter).

    In addition, when I open Query Analyzer, my SERVERNAME\SQLEXPRESS is in the dropdownlist, which I then can select and connect to, run my queries on, etc.

    Now, when I open SQL Server Enterprise Manager, there's only a ConsoleRoot --> Microsoft SQL Servers --> SQL Server Group --> (local)(Windows NT) that's running, under which there are a few DBs (Master, model, msdb, Northwind, Pubs, tempdb)

    If I right-click and wanna do a New SQL Server Registration, I follow the wizard:

    I enter SERVERNAME\SQLEXPRESS in the Available Servers textbox, then I Add it --> then I select Windows authentication --> then I select to add the SQL Server to the existing SQL server group --> and click Finish. Then I get the following error Angry:

    [SQL-DMO]You must use SQL Server 2005 Management tools to connect to this server.

    What freaks me out is that I'm using SQL Server 2000, why would it want me to use  SQL Server 2005 Management tools? Or am I missing something?

    Where can I add the SERVERNAME\SQLEXPRESS server here that I actually need? Why does Enterprise Manager not "see" my SERVERNAME\SQLEXPRESS? Sad.

     Please advise Idea

     

  •  08-03-2008, 22:56 13858 in reply to 13857

    Re: Login failed

    SQLExpress is the instance name for SQL Server 2005's express version. If you connect to SERVERNAME and to SERVERNAME\SQLEXPRESS from query analyser and run the query

    select @@version

    what do you see for each?

    If SERVERNAME\SQLEXPRESS is SQL 2005 (very likely), you cannot use enterprise manager to connect to it. You will need to download management studio express from the MS download site, as SQL 2005 instances cannot be managed from enterprise manager.

    As for your login problem, the error indicates tha while the login succeeded, the login's default database, or the database requested in the login string was not accessible, either missing or offline.

    Check the connection string, see if you have a database specified. If not, check the login and see what its default database is. Check that the database exists, is accessible and that the login has a user mapped to that DB 


    Gail Shaw - SQL In the Wild
    SQL Server MVP
    --
    Chaos, panic and disorder. My job here is done!
  •  08-16-2008, 21:26 14069 in reply to 13858

    Re: Login failed

    Thank you GilaMonster.

    You spared me from a huge lot of frustration and fury!!!

    Smile

     

View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems