Cannot open database "DatabaseName" requested by the login. The login failed.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Cannot open database "DatabaseName" requested by the login. The login failed.

  1. #1
    Join Date
    Aug 2011
    Posts
    5

    Cannot open database "DatabaseName" requested by the login. The login failed.

    Greetings,

    I have a local environment on my Windows 7/SQL Express 2008/IIS 7 laptop. I am working on getting some asp code with vb script to work.

    I am working on a project from work and need to setup a test/development area.

    Here is the error and part of the code:

    Error:
    Microsoft OLE DB Provider for SQL Server error '80004005'

    Cannot open database "DBName" requested by the login. The login failed.

    /servermgmt/framelist.asp, line 51

    Code:
    <%@ Language=VBScript %>
    <%
    Dim sConnection, objConn , objRS
    
    sConnection = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DBName;Data Source=LAPTOP1\SQLEXPRESS;"
    
    
    Set objConn = Server.CreateObject("ADODB.Connection")  "****** Line 51 ******"
    
    objConn.Open(sConnection)
    Set objRS = objConn.Execute("SELECT SERVER_NAME, Primary_IP, STATUS,  FROM server WHERE STATUS <> 'Decommissioned' ORDER BY SERVER_NAME")
    
    additional code....
    %>
    Let me know if more information is needed.

    The page name is serverlist.asp.

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,886

    Re: Cannot open database "DatabaseName" requested by the login. The login failed.

    [ moved thread ]
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Aug 2011
    Posts
    5

    Re: Cannot open database "DatabaseName" requested by the login. The login failed.

    OK, after an exhausting research on the web I found a quick resolution. This may not be the right solution but it worked for me.

    Under Microsoft SQL Server Management Studio > Security > Logins > Builtin\Users...right click and go to Properties > User Mapping > select DB and select under Database role membership for: DB db_owner.

    As soon as I did this, I was able to run my asp page.

    Hope this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center