KB Issue
When connecting your ASP Classic or ASP.NET script to a SQL Server database, you may receive the following error, if the database does not exist.
Issue Details
When connecting to SQL Server through ASP Classic or ASP.NET, and the database that is defined in the Connection script, does not exist, you will receive the following error.
Microsoft OLE DB Provider for SQL Server error '80004005'
Cannot open database "ask" requested by the login. The login failed.
/ACN.asp, line 32
Recreate Issue
Using the following SQL Server ASP Classic connection script to connect to a database that does not exist.
Code Example
Set askConn = CreateObject("ADODB.Connection")
askConn.ConnectionString = "Provider=SQLOLEDB;Data Source=SERVER\INSTANCE NAME;Database=MyDat;User ID=USERNAME;Password=********;"
askConn.Open
The database name is: MyDat
This database does not exist in SQL Server.
Resolve Issue
Using the following SQL Server ASP Classic connection script, to connect to a database that does exist.
Code Example
Set Conn = CreateObject("ADODB.Connection")
Conn.ConnectionString = "Provider=SQLOLEDB;Data Source=SERVER\INSTANCE NAME;Database=MyData;User ID=USERNAME;Password=********;"
Conn.Open
The database name is: MyData
This database exists in SQL Server, and a connection is established.
  1. Ensure the database name is spelled correctly.
  2. Ensure that you have attached the database if you are migrating to another system.