Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

FIX: "Cannot Open Database Requested" Error Connecting to Remote SQL Server


View products that this article applies to.

Symptoms

With the Microsoft OLE DB provider for SQL Server (SQLOLEDB), if you try to access a database on a remote SQL Server that doesn't exist on a local SQL Server, the following error may occur:
Cannot open database requested in login 'database name'. Login fails
This error has been reported when the local computer has Microsoft Data Access Components (MDAC) 2.6, SQL Server 7.0, and Microsoft Windows NT 4.0 Service Pack 6, and the remote computer has SQL Server 7.0. This error does not occur with MDAC 2.6 against a remote SQL Server 2000 server. It also does not occur if the local computer is not running SQL Server.

↑ Back to the top


Resolution

This bug has been fixed in the MDAC version 2.6 Service Pack 1.

↑ Back to the top


Workaround

To work around this error, you can use the SQL Server Client Network utility (Cliconfg.exe) to set up an alias that uses TCP/IP instead of Named Pipes to connect to the server.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Microsoft Data Access Components 2.6 Service Pack 1.

↑ Back to the top


More information

Steps to Reproduce Behavior

NOTE: To reproduce the problem, you will need a local computer with Windows NT 4.0, MDAC 2.6, and SQL Server 7.0, and you will also need a remote SQL Server 7.0.
  1. On the remote SQL Server, create a database named TEST. A database with this name should not exist on your local SQL Server.
  2. Create a new Microsoft Visual Basic EXE project and paste the following code:
    Sub ReproTest
    Dim conn as Object
    Dim rs as Object
    Dim sql as String
      sql = "select db_name(dbid) from master..sysprocesses where " & _
            "spid = @@spid"
      set conn = CreateObject("adodb.connection")
      conn.Provider = "SQLOLEDB"
      conn.Properties("Prompt").Value = adPromptAlways
      conn.Open
      set rs = conn.Execute( sql )
      MsgBox "Current database is " & rs.Fields(0).Value
      rs.Close
      conn.Close
    End Sub
    					
  3. Run the code and when prompted, specify the remote server name, user ID, and password. Click Options and select the TEST database on the remote server.

↑ Back to the top


Keywords: KB283860, kbprovider, kbmdac260sp1fix, kbfix, kbbug, kbhotfixserver, kbqfe

↑ Back to the top

Article Info
Article ID : 283860
Revision : 6
Created on : 11/30/2007
Published on : 11/30/2007
Exists online : False
Views : 305