PRB: Attempting to Open Connection with Non-Existent Provider May Succeed

ID: Q245388


The information in this article applies to:
  • Microsoft Data Access Components version 2.5


SYMPTOMS

While opening a Connection, attempting to specify a non-existent OLE DB provider through the Provider property does not generate an error if the correct provider was previously specified in the ConnectionString argument.


CAUSE

ADO does not recompose the connection string whenever the Provider property is set after specifying the provider in ConnectionString.

The following warning can be found under the Provider Property documentation:


"...; however, specifying a provider in more than one place while calling the Open method can have unpredictable results.... ". 
NOTE: Previous versions of MDAC components can also exhibit this behavior.


RESOLUTION

Specify the OLE DB provider in only one place before opening your Connection object, preferably via the ConnectionString argument.


STATUS

This behavior is by design.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Start a new Visual Basic Standard EXE project. Form1 is added by default.


  2. From the Project menu, click References, and select the "Microsoft ActiveX Data Objects 2.5 Library."


  3. Place the following code in the General Declaration section of Form1:


  4. 
    Private Sub Form_Load()
    
        Dim cn As New Connection
        
        ' Modify the ConnectionString to match your connection parameters
        cn.ConnectionString = "Provider=SQLOLEDB;Data Source=sequel;User ID=sa;"
    
        cn.Provider = "Invalid_Provider_Name"    ' You can keep this non-existent provider name
    
        cn.Open     '<---- No error occurs here
    
        MsgBox "done"
    
    End Sub 
  5. Run the code and note the behavior.


© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Ammar Abuthuraya, Microsoft Corporation


REFERENCES

For more information, please refer to the Platform SDK for Windows 2000.

Additional query words:

Keywords : kbADO kbGrpVCDB kbGrpMDAC kbDSupport kbMDAC250 kbADO250
Version : WINDOWS:2.5
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: January 17, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.