Microsoft KB Archive/223180

From BetaArchive Wiki
Knowledge Base


FIX: DB_E_ERRORSOCCURRED from Jet Provider During OpenDataSource

Article ID: 223180

Article Last Modified on 7/19/2001



APPLIES TO

  • Microsoft Visual Studio 6.0 Service Pack 3
  • Microsoft OLE DB Provider for Jet 4.0



This article was previously published under Q223180

SYMPTOMS

When using the Jet OLE DB Provider 4.0 with a Wizard-generated Active Template Library (ATL) OLE DB Consumer template class, a call to the Open or OpenDataSource method returns an HRESULT of DB_E_ERRORSOCCURRED.

CAUSE

The ATL OLE DB Consumer Wizard generates an OpenDataSource method that includes DBPROP_PERSIST_SENSITIVE_AUTHINFO as one of the initialization properties for the provider. The Jet OLE DB Provider 4.0 is not designed to accept this property and returns an HRESULT of DB_E_ERRORSOCCURRED.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed


MORE INFORMATION

When the ATL OLE DB Consumer Wizard generates a consumer template class using the Jet OLE DB Provider, it generates an OpenDataSource method as in the following code example:

   HRESULT OpenDataSource()
   {
      HRESULT hr;
      CDataSource db;
      CDBPropSet    dbinit(DBPROPSET_DBINIT);

      dbinit.AddProperty(DBPROP_AUTH_CACHE_AUTHINFO, true);
      dbinit.AddProperty(DBPROP_AUTH_ENCRYPT_PASSWORD, false);
      dbinit.AddProperty(DBPROP_AUTH_MASK_PASSWORD, false);
      dbinit.AddProperty(DBPROP_AUTH_PASSWORD, OLESTR(""));
      dbinit.AddProperty(DBPROP_AUTH_PERSIST_ENCRYPTED, false);
      dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);
      dbinit.AddProperty(DBPROP_AUTH_USERID, OLESTR("Admin"));
      dbinit.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR("C:\\NW97.mdb"));
      dbinit.AddProperty(DBPROP_INIT_MODE, (long)16);
      dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);
      dbinit.AddProperty(DBPROP_INIT_PROVIDERSTRING, OLESTR(""));
      dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033);

      hr = db.Open(_T("Microsoft.Jet.OLEDB.4.0"), &dbinit);
      if (FAILED(hr))
         return hr;

      return m_session.Open(db);
   }
                

If you comment out the following line, the method does not generate a DB_E_ERRORSOCCURRED HRESULT with the Jet OLE DB Provider 4.0:

   // dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);
                

The updated ATL OLE DB Consumer Wizard installed by Visual C++ version 6.0 Service Pack 3 does not include this line of code when it generates a consumer template class for the provider, thus avoiding this error.

Keywords: kbbug kbfix kbconsumer kbdatabase kbjet kbvs600sp3fix KB223180