Cannot open database "DatabaseName" requested by the login. The login failed.
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:
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
<%@ 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 ******"
Set objRS = objConn.Execute("SELECT SERVER_NAME, Primary_IP, STATUS, FROM server WHERE STATUS <> 'Decommissioned' ORDER BY SERVER_NAME")
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.