Microsoft KB Archive/269495

= PRB: &quot;Multiple-step OLE DB operation generated errors&quot; when opening ADO connection =

Article ID: 269495

Article Last Modified on 11/24/2004

-

APPLIES TO


 * Microsoft ActiveX Data Objects 2.0
 * Microsoft ActiveX Data Objects 2.1
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft ActiveX Data Objects 2.6
 * Microsoft ActiveX Data Objects 2.7

-



This article was previously published under Q269495



Important This article contains information about modifying the registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. For information about how to back up, restore, and edit the registry, click the following article number to view the article in the Microsoft Knowledge Base:

256986 Description of the Microsoft Windows Registry



SYMPTOMS
When you try to open an ActiveX Data Objects (ADO) connection, you may receive the following error message:

Run-time error '-2147217887 (80040e21):'

Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.



CAUSE
The following are two possible causes of this error:
 * In the registry, under the key for an OLE DB provider's CLSID, there may be an entry named OLEDB_SERVICES. If the OLE DB provider that is used to make the ADO connection does not have the OLEDB_SERVICES entry, and ADO tries to set up a property that is not supported by the provider, the error occurs. For more information about this registry entry, see the &quot;Resolution&quot; section.
 * If OLEDB_SERVICES entry exists but there is a problem in the ADO connection string, the error occurs.

If the OLEDB_SERVICES registry entry is not present, the call to set up a property is made directly to the provider. If the provider does not support the property, the SetProperties OLE DB call made by ADO will fail. This is a fatal failure if the property is required to make a connection. If the property was explicitly included in the connection string, it is probably required.

If the property setting is optional, the failure is not fatal. This is the case when you connect without explicitly setting the property in the connection string. In this case, ADO sets the property to True but marks it as optional.



RESOLUTION
To work around this problem, use one of the following methods:  Do not use the &quot;Persist Security Info&quot; keyword in your ADO connection string. Add the OLEDB_SERVICES registry entry as follows:

Note Only create the OLEDB_SERVICES value in the registry keys of providers that support COM aggregation. The Exchange OLE DB provider does not support COM aggregation, and when you create this values, you receive the following error message:

0x80040E22

Non-NULL controlling IUnknown was specified, and either the requested interface was not IUnknown, or the provider does not support COM aggregation.

Warning If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.  Start Registry Editor. In the registry under HKEY_CLASSES_ROOT\CLSID, find the CLSID of the OLE DB provider. For example, the following registry key is for the Microsoft OLE DB Provider for SQL Server (SQLOLEDB):

HKEY_CLASSES_ROOT\CLSID\{0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}

Click the CLSID, and then on the Edit menu, click Add Value and add the following registry value:

Value Name: OLEDB_SERVICES

Data Type: REG_DWORD

Value: 0xFFFFFFFF

Note To find the CLSID for the provider you are using, search for the provider's ProgID (SQLOLEDB, for example) in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Classes\. Under the ProgID, there will be a key named CLSID.  If these conditions are satisfied and you still receive the error, examine your connection string for other possible errors.</li></ul>

<div class="moreinformation_section">

Steps to reproduce the behavior
Paste the following code in a Microsoft Visual Basic Standard EXE project, set a Project Reference to Microsoft ActiveX Data Objects, and then run it. The error occurs if you use the DTSFlatFile provider or any OLE DB provider that does not support one of the properties in the connection string, such as &quot;Persist Security Info&quot;. Private Sub Command1_Click

Dim cn As New Connection

cn.Open &quot;Provider=DTSFlatFile;Persist Security Info=True;&quot; & _ &quot;Data Source=Mysql;Mode=Read;File Format=0;File Type=1;&quot; & _ &quot;Skip Rows=0;First Row Column Name=False;Number of Column=0;&quot; & _ &quot;Max characters per delimited column=255;&quot; '<-- Error Occurs Here End Sub

<div class="references_section">