Microsoft KB Archive/269495

From BetaArchive Wiki

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 "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.

RESOLUTION

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:

    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.

    1. Start Registry Editor.
    2. 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.


MORE INFORMATION

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 Connection

cn.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
                

REFERENCES

For additional information about this error, click the following article numbers to view the articles in the Microsoft Knowledge Base:

228935 FIX: Uninitialized string variables, empty string values, Jet provider, and errors occurred


253157 BUG: Identity field remains read-only after executing SET IDENTITY_INSERT ON statement


Keywords: kbprovider kbprb KB269495