CFF KB - Carrz-Fox-Fire Promotions Knowledge Base

CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.
  • Breadrumbs:
  • Microsoft OLE DB Provider for SQL Server error '80004005' Cannot open database

  • CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
    Share With Friends (Updated 6-8-2010)
  • Article ID:
    164
  • Date Created
    Wednesday, January 18, 2012
  • Last Updated
    Wednesday, June 20, 2012
  • This Article Has been Viewed
    5562 times
  • Short Desc
    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.
  • 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
    To recreate this issue.

    Using the following SQL Server ASP Classic connection script, to connect to a database that does not exist.

    <%
    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
    To resolve this issue.

    Using the following SQL Server ASP Classic connection script, to connect to a database that does exist.

    <%
    Set askConn = CreateObject("ADODB.Connection")
    askConn.ConnectionString = "Provider=SQLOLEDB;Data Source=SERVER\INSTANCE_NAME;Database=MyData;User ID=USERNAME;Password=********;"
    askConn.Open
    %>


    The database name is: MyData
    This database, does exist in SQL Server, and a connection is made.

    Make sure that you have the name of the database spelled correctly.
    (or)
    Make sure that you have attached the database if you are migrating to another system.