FIX: DB_E_ERRORSOCCURRED from Jet Provider During OpenDataSource

ID: Q223180


The information in this article applies to:
  • Microsoft Visual Studio 6.0 SP3
  • Microsoft OLE DB Provider for Jet, version 4.0


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 this to be a bug in the Microsoft products 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:

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

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

Additional query words:

Keywords : kbservicepack kbDatabase kbJET kbConsumer kbVS600sp2 kbVS600SP1 kbVS600sp3fix kbGrpVCDB
Version : WINDOWS:4.0,6.0 SP3
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: May 19, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.