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:
  • SQL Server error '80004005' - Cannot open database "db_name" requested by the login. The login failed. for SQL Availability Listener connection string

  • 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:
    228
  • Date Created
    Monday, May 18, 2020
  • Last Updated
    Monday, May 18, 2020
  • This Article Has been Viewed
    558 times
  • Short Desc
    When connecting to SQL Server Availability Listener, you may experience the following error.
    Cannot open database "db_name" requested by the login. The login failed.
  • Details
    In this article, we are going to look at two different SQL server database connection strings used in ASP Classic. (The strings will also work in ASP.NET)
    The error we were faced with this issue.

     
    Microsoft OLE DB Provider for SQL Server error '80004005'
    Cannot open database "db_name" requested by the login. The login failed.
    /page.asp, line 10
  • Recreate Issue
    Connect string to a SQL Listener will fail using the following connection string.

    <%
    Set CFFNConn = CreateObject("ADODB.Connection")
    CFFNConn.ConnectionString = "Provider=SQLOLEDB;Data Source=SQLListener,2433;Database=C2345_cs;User ID=username;Password=******;"
    CFFNConn.Open
    %>


    The reason
    The database name [C2345_cs] is the actual name of the database file. Which is what we use to connect to with a regular connection to SQL Server from our applications.
  • Resolve Issue
    Using the following connection string will work without issue to connect to our SQL Listener.

    <%
    Set CFFNConn = CreateObject("ADODB.Connection")
    CFFNConn.ConnectionString = "Provider=SQLOLEDB;Data Source=SQLListener,2433;Database=cs;User ID=username;Password=******;"
    CFFNConn.Open
    %>


    The reason
    The database name in this connection is the actual name of the database name in SSMS (SQL Server Management Studio).
    When we create a database in SSMS, we give it a name, rather long or short.
    This name is what SQL Listener needs to connect to the database.
    So, in the [Recreate] section above, the actual database file name is [C2345_cs]. The renaming of the database was done when I was using an outside hosting provider. And this is the name we had to use for our connection strings to work.
    Using the SQL Listener, we no longer have to use the file name in our connection strings.


    --------
    Related Articles


    Microsoft OLE DB Provider for SQL Server (0x80004005) Cannot open database«

    Microsoft OLE DB Provider for SQL Server error '80004005' Cannot open database«