How do I access an MDB's Custom Properties 
Author Message
 How do I access an MDB's Custom Properties

How does the MFC DAO implementation provide access to the Custom Properites
of an MDB (open an MDB in Access, and select 'Custom Properties'...)?

I've looked all over.  The Properties collection of the database doesn't
contain any of the custom properties.
Anybody worked with/encountered this problem?

Thanks!

-P



Sat, 02 Mar 2002 03:00:00 GMT  
 How do I access an MDB's Custom Properties

Quote:

>How does the MFC DAO implementation provide access to the Custom Properites
>of an MDB (open an MDB in Access, and select 'Custom Properties'...)?

>I've looked all over.  The Properties collection of the database doesn't
>contain any of the custom properties.
>Anybody worked with/encountered this problem?

The problem is that you can't do it through MFC's implementation, you have
to go deeper and get at the DAO object itself.  Here is a method I wrote
(that I got from someone else :->) that does just that:

CString PECDaoDatabase::GetCustomProperty(CString psPropertyName)
{
 //
 // OVERVIEW:
 // Get the value for the given Custom Property
 //
 DAOContainers *pColCont = NULL;
 DAOContainer *pCont = NULL;
 DAODocuments *pColDoc = NULL;
 DAODocument *pDoc = NULL;
 DAOProperties *pColProp = NULL;
 DAOProperty *pProp = NULL;

#ifdef  _UNICODE
 COleVariant ovContainer(_T("Databases"), VT_BSTR);
 COleVariant ovDocument(_T("UserDefined"), VT_BSTR);
 COleVariant ovProperty(psPropertyName, VT_BSTR);
#else
 COleVariant ovContainer(_T("Databases"), VT_BSTRT);
 COleVariant ovDocument(_T("UserDefined"), VT_BSTRT);
 COleVariant ovProperty(psPropertyName, VT_BSTRT);
#endif
 COleVariant ovValue;

 ASSERT(IsOpen());
 TRY
 {
  DAO_CHECK(m_pDAODatabase->get_Containers(&pColCont));
  DAO_CHECK(pColCont->get_Item(ovContainer, &pCont));
  DAO_CHECK(pCont->get_Documents(&pColDoc));
  DAO_CHECK(pColDoc->get_Item(ovDocument, &pDoc));
  DAO_CHECK(pDoc->get_Properties(&pColProp));
  DAO_CHECK(pColProp->get_Item(ovProperty, &pProp));
  if (pProp != NULL)
  {
   DAO_CHECK(pProp->get_Value(&ovValue));
   return TrimString(PECOVCrack::strVARIANT(ovValue));
  }
 }
 END_TRY
 return _T("");

Quote:
}



Mon, 04 Mar 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to access Custom Database Properties of a Access 97 database programmatically

2. Can't use complex properties in custom control

3. VB's mousepointer property not working when set from event of custom ATL control

4. VB5 does not like my control's custom property pages

5. Strange ODBC errors using DAO to access linked tables in Access .MDB

6. Can I access an access (mdb) file within DOS

7. accessing outlook from vc (via access mdb file)

8. Jet 4.0 crashes when accessing an Access 97 .mdb

9. Converting Access 97 MDB file to Access 2000

10. Access control's property with a string?

11. can't access class property

12. Accessing Word 97's ambient properties

 

 
Powered by phpBB® Forum Software