This article was previously published under Q269495
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
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.
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 "Resolution" 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.
To work around this problem, use one of the following methods:
Do not use the "Persist Security Info" 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:
Non-NULL controlling IUnknown was specified, and either the requested interface was not IUnknown, or the provider does not support COM aggregation.
Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756 How to back up and restore the registry in Windows
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):
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.
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 "Persist Security Info".
Private Sub Command1_Click()Dim cn As New Connectioncn.Open "Provider=DTSFlatFile;Persist Security Info=True;" & _ "Data Source=Mysql;Mode=Read;File Format=0;File Type=1;" & _ "Skip Rows=0;First Row Column Name=False;Number of Column=0;" & _ "Max characters per delimited column=255;" '<------ Error Occurs Here End Sub
For additional information about this error, click the following article numbers to view the articles in the Microsoft Knowledge Base: