home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2000 September / VPR0009A.BIN / VS60SP4JPN / support / dbdao.cpp < prev    next >
C/C++ Source or Header  |  1998-09-30  |  88KB  |  4,435 lines

  1. /************************************************************************
  2. **    D B D A O . C P P                                                    *
  3. **                                                                        *
  4. *************************************************************************
  5. ** Copyright (C) 1996 by Microsoft Corporation                             *
  6. **           All Rights Reserved                                             *
  7. ************************************************************************/
  8. /*
  9.     DBDAO.CPP
  10.  
  11.     Source code for DBDAO C++ classes
  12. */
  13.  
  14. #include "stdafx.h"
  15. #include "resource.h"
  16.  
  17. #define _DB_NOFORCE_LIBS
  18. #include <DBDAO.h>
  19.  
  20.  
  21.  
  22. /*****************************************************************************
  23. * CdbException
  24. */
  25. CONSTRUCTOR            CdbException::CdbException(
  26.     HRESULT    hr)
  27.     {
  28.     m_hr = hr;
  29.     }
  30.  
  31. /*****************************************************************************
  32. * CdbBookmark
  33. */
  34. CONSTRUCTOR            CdbBookmark::CdbBookmark() //default
  35.     {
  36.     vt        = 0;
  37.     parray    = NULL;
  38.     }
  39.  
  40.  
  41. CONSTRUCTOR            CdbBookmark::CdbBookmark(
  42.     LPSAFEARRAY psa)
  43.     {
  44.     vt        = VT_ARRAY|VT_UI1;
  45.     parray    = psa;
  46.     }
  47.  
  48. CONSTRUCTOR            CdbBookmark::CdbBookmark(
  49.     const CdbBookmark &o)
  50.     {
  51.     VariantInit(this);
  52.     DAOMFC_CALL(VariantCopy(this, (LPVARIANT)&o));
  53.     }
  54.  
  55. CdbBookmark &            CdbBookmark::operator =(
  56.     const CdbBookmark &o)
  57.     {
  58.     DAOMFC_CALL(VariantCopy(this, (LPVARIANT)&o));
  59.     return *this;
  60.     }
  61.  
  62.                     CdbBookmark::operator LPSAFEARRAY(
  63.     VOID)
  64.     {
  65.     return (vt&VT_ARRAY?parray:NULL);
  66.     }
  67.  
  68. /*****************************************************************************
  69. * CdbOleObject
  70. */
  71. CONSTRUCTOR            CdbOleObject::CdbOleObject(
  72.     VOID)
  73.     {
  74.     m_punkInterface = NULL;
  75.     }
  76.  
  77. CdbOleObject &        CdbOleObject::operator =(
  78.     CdbOleObject &o)
  79.     {
  80.     SetInterface(o.m_punkInterface, TRUE);
  81.     return *this;
  82.     }
  83.  
  84. DESTRUCTOR            CdbOleObject::~CdbOleObject(
  85.     VOID)
  86.     {
  87.  
  88.     if (m_punkInterface)
  89.         m_punkInterface->Release();
  90.     }
  91.  
  92. BOOL                CdbOleObject::StartOLE(
  93.     )
  94.     {
  95.     HRESULT    hr;
  96.  
  97.     DAOMFC_CALL(hr=CoInitialize(NULL));
  98.  
  99.     return SUCCEEDED(hr);
  100.     }
  101.  
  102. VOID                CdbOleObject::SetInterface(
  103.     LPUNKNOWN    punk,
  104.     BOOL        bAddRef)    // = FALSE
  105.     {
  106.     // Get rid of existing interface, if we have one
  107.     if (m_punkInterface)
  108.         m_punkInterface->Release();
  109.  
  110.     // Addref new interface so we have a valid reference
  111.     if (bAddRef && punk)
  112.         punk->AddRef();
  113.  
  114.     m_punkInterface = punk;
  115.     OnInterfaceChange();
  116.     }
  117.  
  118. VOID                CdbOleObject::SetInterface(
  119.     REFIID    riidClass,
  120.     REFIID    riidInterface)
  121.     {
  122.     LPUNKNOWN    punk;
  123.  
  124.     if (!StartOLE())
  125.         return;
  126.  
  127.     DAOMFC_CALL(CoCreateInstance(riidClass, NULL, CLSCTX_INPROC_SERVER, riidInterface, (LPVOID *)&punk));
  128.  
  129.     SetInterface(punk);
  130.     }
  131.  
  132. VOID                CdbOleObject::SetInterfaceLic(
  133.     REFIID    riidClass,
  134.     REFIID    riidInterface)
  135.     {
  136.     LPUNKNOWN    punk;
  137.     BSTR        m_bstrKey = NULL;
  138.     LPCLASSFACTORY2 pClassFactory2 = NULL;
  139.  
  140.     if (!StartOLE())
  141.         return;
  142.  
  143. #if _MSC_VER >= 1000
  144.     m_bstrKey = SysAllocString(CdbWide((LPSTR)szKEY));
  145. #else
  146.     m_bstrKey = SysAllocString(_T(szKEY));
  147. #endif
  148.  
  149.     DAOMFC_CALL(CoGetClassObject(riidClass, CLSCTX_INPROC_SERVER, NULL, IID_IClassFactory2, (void**)&pClassFactory2));
  150.     
  151.     ASSERT(pClassFactory2 != NULL);
  152.  
  153.     DAOMFC_CALL(pClassFactory2->CreateInstanceLic(NULL, NULL, riidInterface, m_bstrKey,(LPVOID *)&punk));
  154.         
  155.     if (NULL!=m_bstrKey)
  156.         SysFreeString(m_bstrKey);
  157.  
  158.     SetInterface(punk);
  159.  
  160.     DAOMFC_CALL(pClassFactory2->Release());
  161.     }
  162.  
  163.  
  164. LPUNKNOWN            CdbOleObject::GetInterface(
  165.     BOOL    bAddRef,                // = FALSE
  166.     BOOL    bThrowException) const    // = TRUE
  167.     {
  168.     if (!m_punkInterface)
  169.         {
  170.         // Oops! The OLE interface has not been set yet a request is
  171.         // being made to access the interface!
  172.  
  173.         if (bThrowException)
  174.             {
  175.             // First: Set the rich error info.
  176.             #if _MSC_VER >= 1000
  177.             SetRichErrorInfo(L"DBDAO", L"Object OLE interface not set.", NULL, 0L);
  178.             #endif
  179.             // Second: Throw an exception.
  180.             DAOMFC_CALL(E_FAIL);
  181.             }
  182.         else
  183.             return NULL;
  184.         }
  185.  
  186.     if (bAddRef)
  187.         m_punkInterface->AddRef();
  188.  
  189.     return m_punkInterface;
  190.     }
  191.  
  192. VOID                CdbOleObject::OnInterfaceChange(
  193.     VOID)
  194.     {
  195.     // By default do nothing on interface change
  196.     }
  197.  
  198. VOID                CdbOleObject::SetRichErrorInfo(
  199.     LPOLESTR    pstrSource,
  200.     LPOLESTR    pstrDescription,
  201.     LPOLESTR    pstrHelpFile,
  202.     ULONG        ulHelpID) const
  203.     {
  204.     ICreateErrorInfo *    pcei;
  205.     IErrorInfo *        pei;
  206.  
  207.     if (FAILED(CreateErrorInfo(&pcei)))
  208.         return;
  209.  
  210.     if (FAILED(pcei->QueryInterface(IID_IErrorInfo, (LPVOID *)&pei)))
  211.         {
  212.         pcei->Release();
  213.         return;
  214.         }
  215.  
  216.     pcei->SetGUID(IID_NULL);
  217.  
  218.     if (pstrSource)
  219.         pcei->SetSource(pstrSource);
  220.     if (pstrDescription)
  221.         pcei->SetDescription(pstrDescription);
  222.     if (pstrHelpFile)
  223.         pcei->SetHelpFile(pstrHelpFile);
  224.  
  225.     pcei->SetHelpContext(ulHelpID);
  226.  
  227.     SetErrorInfo((DWORD)0, pei);
  228.  
  229.     pei->Release();
  230.     pcei->Release();
  231.     }
  232.  
  233.  
  234. /*****************************************************************************
  235. * CdbObject
  236. */
  237. CONSTRUCTOR            CdbObject::CdbObject(
  238.     VOID)
  239.     {
  240.     }
  241.  
  242. CONSTRUCTOR            CdbObject::CdbObject(
  243.     LPUNKNOWN    punk,
  244.     BOOL        bAddRef)    // = FALSE
  245.     {
  246.     SetInterface(punk, bAddRef);
  247.     }
  248.  
  249. CString                CdbObject::GetName(
  250.     VOID)
  251.     {
  252.      #if _MSC_VER >= 1000
  253.      SetRichErrorInfo(L"DBDAO", L"Method not supported", NULL, 0);
  254.     #endif
  255.     DAOMFC_CALL(E_FAIL);
  256.     return (LPCTSTR)NULL;
  257.     }
  258.  
  259. VOID                CdbObject::SetName(
  260.     LPCTSTR pstr)
  261.     {
  262.     UNREFERENCED_PARAMETER(pstr);
  263.     #if _MSC_VER >= 1000
  264.     SetRichErrorInfo(L"DBDAO", L"Method not supported", NULL, 0);
  265.     #endif
  266.     DAOMFC_CALL(E_FAIL);
  267.     }
  268.  
  269. /*****************************************************************************
  270. * CdbStaticCollection
  271. */
  272. // Methods
  273. CdbObject        CdbStaticCollection::ObItem(
  274.     LONG i)
  275.     {
  276.     DAOMFCSCollection *    pcol = (DAOMFCSCollection *)GetInterface();
  277.     LPUNKNOWN            pint = NULL;
  278.  
  279.     if (!pcol)
  280.         return (LPUNKNOWN)NULL;
  281.  
  282.     DAOMFC_CALL(pcol->get_Item(LTV(i), &pint));
  283.  
  284.     return pint;
  285.     }
  286.  
  287. CdbObject        CdbStaticCollection::ObItem(
  288.     LPCTSTR pstr)
  289.     {
  290.     DAOMFCSCollection *    pcol = (DAOMFCSCollection *)GetInterface();
  291.     LPUNKNOWN            pint = NULL;
  292.  
  293.     if (!pcol)
  294.         return (LPUNKNOWN)NULL;
  295.  
  296.     DAOMFC_CALL(pcol->get_Item(STV(pstr), &pint));
  297.  
  298.     return pint;
  299.     }
  300.  
  301. LONG            CdbStaticCollection::GetCount(
  302.     VOID)
  303.     {
  304.     DAOMFCSCollection *    pcol = (DAOMFCSCollection *)GetInterface();
  305.     SHORT                s        = 0;
  306.  
  307.     if (!pcol)
  308.         return 0;
  309.  
  310.     DAOMFC_CALL(pcol->get_Count(&s));
  311.  
  312.     return (LONG)s;
  313.     }
  314.  
  315. VOID            CdbStaticCollection::ObAppend(
  316.     CdbObject &o)
  317.     {
  318.     UNREFERENCED_PARAMETER(o);
  319.     }
  320.  
  321. VOID            CdbStaticCollection::Delete(
  322.     LPCTSTR pstr)
  323.     {
  324.     UNREFERENCED_PARAMETER(pstr);
  325.     }
  326.  
  327. VOID            CdbStaticCollection::Refresh(
  328.     VOID)
  329.     {
  330.     DAOMFCSCollection *    pcol    = (DAOMFCSCollection *)GetInterface();
  331.  
  332.     DAOMFC_CALL(pcol->Refresh());
  333.     }
  334.  
  335. /*****************************************************************************
  336. * CdbDynamicCollection
  337. */
  338. // Methods
  339. CdbObject        CdbDynamicCollection::ObItem(
  340.     LONG i)
  341.     {
  342.     DAOMFCDCollection *    pcol = (DAOMFCDCollection *)GetInterface();
  343.     LPUNKNOWN            pint = NULL;
  344.  
  345.     if (!pcol)
  346.         return (LPUNKNOWN)NULL;
  347.  
  348.     DAOMFC_CALL(pcol->get_Item(LTV(i), &pint));
  349.  
  350.     return pint;
  351.     }
  352.  
  353. CdbObject        CdbDynamicCollection::ObItem(
  354.     LPCTSTR pstr)
  355.     {
  356.     DAOMFCDCollection *    pcol = (DAOMFCDCollection *)GetInterface();
  357.     LPUNKNOWN            pint = NULL;
  358.  
  359.     if (!pcol)
  360.         return (LPUNKNOWN)NULL;
  361.  
  362.     DAOMFC_CALL(pcol->get_Item(STV(pstr), &pint));
  363.  
  364.     return pint;
  365.     }
  366.  
  367. LONG            CdbDynamicCollection::GetCount(
  368.     VOID)
  369.     {
  370.     DAOMFCDCollection *    pcol = (DAOMFCDCollection *)GetInterface();
  371.     SHORT                s        = 0;
  372.  
  373.     if (!pcol)
  374.         return 0;
  375.  
  376.     DAOMFC_CALL(pcol->get_Count(&s));
  377.  
  378.     return (LONG)s;
  379.     }
  380.  
  381. VOID            CdbDynamicCollection::ObAppend(
  382.     CdbObject &o)
  383.     {
  384.     DAOMFCDCollection *    pcol    = (DAOMFCDCollection *)GetInterface();
  385.     LPDISPATCH    pdisp            = (LPDISPATCH)o.GetInterface();
  386.  
  387.     if (!pdisp)
  388.         return;
  389.  
  390.     DAOMFC_CALL(pcol->Append(pdisp));
  391.     }
  392.  
  393. VOID            CdbDynamicCollection::Delete(
  394.     LPCTSTR pstr)
  395.     {
  396.     DAOMFCDCollection *    pcol    = (DAOMFCDCollection *)GetInterface();
  397.  
  398.     DAOMFC_CALL(pcol->Delete(STB(pstr)));
  399.     }
  400.  
  401. VOID            CdbDynamicCollection::Refresh(
  402.     VOID)
  403.     {
  404.     DAOMFCDCollection *    pcol    = (DAOMFCDCollection *)GetInterface();
  405.  
  406.     DAOMFC_CALL(pcol->Refresh());
  407.     }
  408.  
  409.  
  410. /*****************************************************************************
  411. * Collection implementations
  412. */
  413. DAOMFC_STATIC_COLLECTION_IMPL(CdbErrors, CdbError, DAOErrors, DAOError)
  414. DAOMFC_STATIC_COLLECTION_IMPL(CdbDatabases, CdbDatabase, DAODatabases, DAODatabase)
  415. DAOMFC_STATIC_COLLECTION_IMPL(CdbRecordsets, CdbRecordset, DAORecordsets, DAORecordset)
  416. DAOMFC_STATIC_COLLECTION_IMPL(CdbParameters, CdbParameter, DAOParameters, DAOParameter)
  417. DAOMFC_STATIC_COLLECTION_IMPL(CdbDocuments, CdbDocument, DAODocuments, DAODocument)
  418. DAOMFC_STATIC_COLLECTION_IMPL(CdbContainers, CdbContainer, DAOContainers, DAOContainer)
  419.  
  420. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbProperties, CdbProperty, DAOProperties, DAOProperty)
  421. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbFields, CdbField, DAOFields, DAOField)
  422. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbQueryDefs, CdbQueryDef, DAOQueryDefs, DAOQueryDef)
  423. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbTableDefs, CdbTableDef, DAOTableDefs, DAOTableDef)
  424. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbIndexes, CdbIndex, DAOIndexes, DAOIndex)
  425. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbRelations, CdbRelation, DAORelations, DAORelation)
  426. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbUsers, CdbUser, DAOUsers, DAOUser)
  427. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbGroups, CdbGroup, DAOGroups, DAOGroup)
  428.  
  429. //The Workspaces collection may not have it's interface until the client decides between JET and ODBC
  430. //(because DAO will load Jet or ODBC as soon as the collection is accessed)so until an individual item 
  431. //in the workspaces collection is addressed, keep the interface NULL
  432.  
  433. CdbWorkspace        CdbWorkspaces::Item                (LONG i)         {GetDelayedInterface(); return (DAOWorkspace *)(ObItem(i).GetInterface(TRUE)); }
  434. CdbWorkspace        CdbWorkspaces::Item                (LPCTSTR pstr)    {GetDelayedInterface(); return (DAOWorkspace *)(ObItem(pstr).GetInterface(TRUE)); }
  435. VOID                CdbWorkspaces::Append            (CdbWorkspace &o)    {GetDelayedInterface(); ObAppend(o); }
  436. CdbWorkspace        CdbWorkspaces::operator[]        (LONG i)        {GetDelayedInterface(); return (DAOWorkspace *)(Item(i).GetInterface(TRUE)); }
  437. CdbWorkspace        CdbWorkspaces::operator[]        (LPCTSTR pstr)    {GetDelayedInterface(); return (DAOWorkspace *)(Item(pstr).GetInterface(TRUE)); }
  438.  
  439. VOID            CdbWorkspaces::GetDelayedInterface()
  440.     {
  441.     DAOWorkspaces *        pwrks    = NULL;
  442.  
  443.     // If we have the Engine interface and this interface hasn't been set yet
  444.     // we can try to get it now (Unless the user created DBEngine with an
  445.     // explicit "DONT START"
  446.     if (!m_punkInterface && pDBEng && !m_bDontStart)
  447.         {
  448.         DAOMFC_CALL(pDBEng->get_Workspaces(&pwrks));
  449.         SetInterface(pwrks);
  450.         }
  451.     }
  452.  
  453. //The Connections interface is special cased because it can exist in an unconnected state if the 
  454. //Workspace is a Jet workspace. This implementation makes sure the error info gets
  455. //generated properly from DAO
  456. CdbConnection        CdbConnections::Item            (LONG i)         {CheckInterface(); return (DAOConnection *)(ObItem(i).GetInterface(TRUE)); }
  457. CdbConnection        CdbConnections::Item            (LPCTSTR pstr)    {CheckInterface(); return (DAOConnection *)(ObItem(pstr).GetInterface(TRUE)); }
  458. CdbConnection        CdbConnections::operator[]        (LONG i)        {CheckInterface(); return (DAOConnection *)(Item(i).GetInterface(TRUE)); }
  459. CdbConnection        CdbConnections::operator[]        (LPCTSTR pstr)    {CheckInterface(); return (DAOConnection *)(Item(pstr).GetInterface(TRUE)); }
  460. LONG                CdbConnections::GetCount        (
  461.     VOID)
  462.     {
  463.     DAOMFCSCollection *    pcol;
  464.     SHORT                s        = 0;
  465.     CheckInterface(); 
  466.     
  467.     pcol = (DAOMFCSCollection *)GetInterface();
  468.  
  469.     if (!pcol)
  470.         return 0;
  471.  
  472.     DAOMFC_CALL(pcol->get_Count(&s));
  473.  
  474.     return (LONG)s;
  475.     }
  476.  
  477. VOID                CdbConnections::Refresh(
  478.     VOID)
  479.     {
  480.     DAOMFCSCollection *    pcol;
  481.     CheckInterface();
  482.     pcol    = (DAOMFCSCollection *)GetInterface();
  483.  
  484.     DAOMFC_CALL(pcol->Refresh());
  485.  
  486.     }
  487.  
  488.  
  489. //Force DAO to throw an exception if the interface is missing. This is an indirect way of doing this
  490. //by checking for a missing interface and then asking the DAO workspace to return it. If the Connections
  491. //interface throws an exception it's most likely because this is a Jet workspace
  492. VOID                CdbConnections::CheckInterface()
  493.     {
  494.     DAOConnections *    pconn    = NULL;
  495.  
  496.     if(!m_punkInterface)
  497.         if(pwrk)
  498.             DAOMFC_CALL(pwrk->get_Connections(&pconn));
  499.     }
  500.  
  501. CONSTRUCTOR        CdbConnections::CdbConnections(
  502.     CdbConnections &Connections)
  503.     {
  504.     DAOConnections *    pconn    = NULL;
  505.  
  506.     //Try to trap the user from getting a Connections copy if this is a Jet workspace
  507.     if(Connections.pwrk)
  508.         DAOMFC_CALL(Connections.pwrk->get_Connections(&pconn));
  509.  
  510.     SetInterface(Connections.m_punkInterface, TRUE);
  511.     }
  512.  
  513.  
  514. CdbConnections &    CdbConnections::operator =(
  515.     CdbConnections &Connections)
  516.     {
  517.     DAOConnections *    pconn    = NULL;
  518.  
  519.     //Try to trap the user from getting a Connections copy if this is a Jet workspace
  520.     if(Connections.pwrk)
  521.         DAOMFC_CALL(Connections.pwrk->get_Connections(&pconn));
  522.  
  523.     SetInterface(Connections.m_punkInterface, TRUE);
  524.     return *this;
  525.     }
  526.  
  527. /*****************************************************************************
  528. * CdbLastOLEError
  529. *
  530. * NOTE:    This object is meant to be used inside of exception handlers so
  531. *        exceptions should not be raised by these member functions.
  532. */
  533. CONSTRUCTOR                CdbLastOLEError::CdbLastOLEError(
  534.     VOID)
  535.     {
  536.     IErrorInfo *    pei = NULL;
  537.  
  538.     GetErrorInfo(0L, &pei);
  539.  
  540.     CdbOleObject::SetInterface((LPUNKNOWN)pei);
  541.     }
  542.  
  543. CString                    CdbLastOLEError::GetSource(
  544.     VOID)
  545.     {
  546.     IErrorInfo *    pei = (IErrorInfo *)GetInterface(FALSE, FALSE);
  547.     CdbBSTR            bstr;
  548.  
  549.     if (!pei)
  550.         return (LPOLESTR)NULL;
  551.  
  552.     pei->GetSource(bstr);
  553.  
  554.     return *((BSTR *)bstr);
  555.     }
  556.  
  557. CString                    CdbLastOLEError::GetDescription(
  558.     VOID)
  559.     {
  560.     IErrorInfo *    pei = (IErrorInfo *)GetInterface(FALSE, FALSE);
  561.     CdbBSTR            bstr;
  562.  
  563.     if (!pei)
  564.         return (LPOLESTR)NULL;
  565.  
  566.     pei->GetDescription(bstr);
  567.  
  568.     return *((BSTR *)bstr);
  569.     }
  570.  
  571. CString                    CdbLastOLEError::GetHelpFile(
  572.     VOID)
  573.     {
  574.     IErrorInfo *    pei = (IErrorInfo *)GetInterface(FALSE, FALSE);
  575.     CdbBSTR            bstr;
  576.  
  577.     if (!pei)
  578.         return (LPOLESTR)NULL;
  579.  
  580.     pei->GetHelpFile(bstr);
  581.  
  582.     return *((BSTR *)bstr);
  583.     }
  584.  
  585. DWORD                    CdbLastOLEError::GetHelpContext(
  586.     VOID)
  587.     {
  588.     IErrorInfo *    pei = (IErrorInfo *)GetInterface(FALSE, FALSE);
  589.     DWORD            dw    = 0;
  590.  
  591.     if (!pei)
  592.         return 0;
  593.  
  594.     pei->GetHelpContext(&dw);
  595.  
  596.     return dw;
  597.     }
  598.  
  599. /*****************************************************************************
  600. * CdbDBEngine
  601. */
  602. // Administration
  603. CONSTRUCTOR            CdbDBEngine::CdbDBEngine(
  604.     DAODBEngine *    peng,
  605.     BOOL            bAddRef)    // = FALSE
  606.     {
  607.  
  608.     m_bStarted = TRUE;
  609.     Workspaces.m_bDontStart = FALSE;
  610.     CdbOleObject::SetInterface((LPUNKNOWN)peng, bAddRef);
  611.     }
  612.  
  613.  
  614. CONSTRUCTOR            CdbDBEngine::CdbDBEngine(
  615.     BOOL    bPrivate,        // = FALSE
  616.     BOOL    bStart,            // = TRUE
  617.     LPCTSTR pstrIniPath,    // = NULL
  618.     LPCTSTR pstrDefUser,    // = NULL
  619.     LPCTSTR pstrDefPW,        // = NULL
  620.     LONG    lType)            // = dbUseJet
  621.     {
  622.     m_bStarted = FALSE;
  623.  
  624.     CdbOleObject::SetInterfaceLic(bPrivate?CLSID_CDAOPrivDBEngine:CLSID_CDAODBEngine,dbIID_IDAODBEngine);
  625.                                                                                   
  626.     if (pstrIniPath)
  627.         SetIniPath(pstrIniPath);
  628.     if (pstrDefUser)
  629.         SetDefaultUser(pstrDefUser);
  630.     if (pstrDefPW)
  631.         SetDefaultPassword(pstrDefPW);
  632.     
  633.     //Jet or ODBC?
  634.     SetDefaultType(lType);    
  635.     
  636.     if (bStart)
  637.         {
  638.         Start();
  639.         Workspaces.m_bDontStart = FALSE;
  640.         }
  641.     else
  642.         {
  643.         //User explicitly asked us NOT to start the engine, so set a flag 
  644.         //so we don't "help" by starting it later to get the workspaces collection
  645.         Workspaces.m_bDontStart = TRUE;
  646.         }
  647.  
  648.     }
  649.  
  650. CONSTRUCTOR            CdbDBEngine::CdbDBEngine(
  651.     const CdbDBEngine &o)
  652.     {
  653.     Workspaces.m_bDontStart = FALSE;
  654.     SetInterface(o.GetInterface(TRUE));
  655.     //Workspaces collection may be delayed.
  656.     Workspaces.SetDBEngine((DAODBEngine *)GetInterface());
  657.     }
  658.  
  659. CdbDBEngine &        CdbDBEngine::operator =(
  660.     const CdbDBEngine &o)
  661.     {
  662.     SetInterface(o.GetInterface(TRUE));
  663.     return *this;
  664.     }
  665.  
  666. VOID                CdbDBEngine::OnInterfaceChange(
  667.     VOID)
  668.     {
  669.     DAODBEngine    *        peng    = (DAODBEngine *)GetInterface();
  670.     DAOProperties *        pprps    = NULL;
  671.     DAOWorkspaces *        pwrks    = NULL;
  672.     DAOErrors *            perrs    = NULL;
  673.  
  674.     if (peng && m_bStarted)
  675.         {
  676.         peng->get_Properties(&pprps);
  677.  
  678.         //Delay this so we can start in either Jet or ODBC - 3.5
  679.         //peng->get_Workspaces(&pwrks);
  680.         peng->get_Errors(&perrs);
  681.         }
  682.  
  683.     Properties.SetInterface(pprps);
  684.     Workspaces.SetDBEngine(peng);
  685.     Errors.SetInterface(perrs);
  686.     }
  687.  
  688. VOID                CdbDBEngine::Start(
  689.     VOID)
  690.     {
  691.     // If not started then start and setup collections
  692.     if (!m_bStarted)
  693.         {
  694.         m_bStarted = TRUE;
  695.         Workspaces.m_bDontStart = FALSE;
  696.         OnInterfaceChange();
  697.         }
  698.     }
  699.  
  700. VOID                CdbDBEngine::SetOption(
  701.     long lOption,
  702.     LPVARIANT pvValue)
  703.     {
  704.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  705.  
  706.     DAOMFC_CALL(peng->SetOption(lOption, *pvValue));
  707.  
  708.     }
  709. // Properties
  710. VOID                CdbDBEngine::SetDefaultPassword(
  711.     LPCTSTR    pstr)
  712.     {
  713.     SPROPSET(DAODBEngine, put_DefaultPassword, pstr);    
  714.     }
  715.  
  716. VOID                CdbDBEngine::SetDefaultUser(
  717.     LPCTSTR    pstr)
  718.     {
  719.     SPROPSET(DAODBEngine, put_DefaultUser, pstr);
  720.     }
  721.  
  722. VOID                CdbDBEngine::SetIniPath(
  723.     LPCTSTR    pstr)
  724.     {
  725.     SPROPSET(DAODBEngine, put_IniPath, pstr);
  726.     }
  727.  
  728. CString                CdbDBEngine::GetIniPath(
  729.     VOID)
  730.     {
  731.     SPROPGET(DAODBEngine, get_IniPath);
  732.     }
  733.  
  734. VOID                CdbDBEngine::SetDefaultType(
  735.     LONG    l)
  736.     {
  737.     LPROPSET(DAODBEngine, put_DefaultType, l);
  738.     }
  739.  
  740. LONG                CdbDBEngine::GetDefaultType(
  741.     VOID)
  742.     {
  743.     LPROPGET(DAODBEngine, get_DefaultType);
  744.     }
  745.  
  746. VOID                CdbDBEngine::SetLoginTimeout(
  747.     SHORT    s)
  748.     {
  749.     WPROPSET(DAODBEngine, put_LoginTimeout, s);
  750.     }
  751.  
  752. SHORT                CdbDBEngine::GetLoginTimeout(
  753.     VOID)
  754.     {
  755.     WPROPGET(DAODBEngine, get_LoginTimeout);
  756.     }
  757.  
  758. CString                CdbDBEngine::GetVersion(
  759.     VOID)
  760.     {
  761.     SPROPGET(DAODBEngine, get_Version);
  762.     }
  763.  
  764. CString                CdbDBEngine::GetSystemDB(
  765.     VOID)
  766.     {
  767.     SPROPGET(DAODBEngine, get_SystemDB);
  768.     }
  769.  
  770. VOID                CdbDBEngine::SetSystemDB(
  771.     LPCTSTR    pstr)
  772.     {
  773.     SPROPSET(DAODBEngine, put_SystemDB, pstr);    
  774.     }
  775.  
  776. // Methods
  777. CdbWorkspace         CdbDBEngine::CreateWorkspace(
  778.     LPCTSTR    pstrName,
  779.     LPCTSTR    pstrUser,
  780.     LPCTSTR    pstrPassword,
  781.     LONG    lDefaultType) //=dbUseJet
  782.     {
  783.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  784.     DAOWorkspace *    pwrk    = NULL;
  785.  
  786.     if (!peng)
  787.         return (DAOWorkspace *)NULL;
  788.  
  789.     DAOMFC_CALL(peng->CreateWorkspace(STB(pstrName), STB(pstrUser), STB(pstrPassword), OLTV(lDefaultType), &pwrk));
  790.  
  791.     return pwrk;
  792.     }
  793.  
  794. VOID                CdbDBEngine::CompactDatabase(
  795.     LPCTSTR    pstrOldDatabase,
  796.     LPCTSTR    pstrNewDatabase,
  797.     LPCTSTR pstrDstConnect, // = NULL
  798.     LONG    lOptions, // = -1
  799.     LPCTSTR pstrSrcConnect)// = NULL
  800.     {
  801.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  802.     TCHAR        szEmpty[] = {_T("")};
  803.  
  804.     //The DstConnect is an optional argument to DAO, BUT if it isn't
  805.     //supplied DAO ignores the lOptions. So, always supply a DstConnect
  806.     if (!pstrDstConnect) pstrDstConnect = (LPCTSTR)&szEmpty;
  807.  
  808.     DAOMFC_CALL(peng->CompactDatabase(STB(pstrOldDatabase), 
  809.         STB(pstrNewDatabase), 
  810.         STV(pstrDstConnect),
  811.         OLTV(lOptions),
  812.         STV(pstrSrcConnect)));
  813.     }
  814.  
  815. VOID                CdbDBEngine::RepairDatabase(
  816.     LPCTSTR pstrDatabase)
  817.     {
  818.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  819.  
  820.     DAOMFC_CALL(peng->RepairDatabase(STB(pstrDatabase)));
  821.     }
  822.  
  823. VOID                CdbDBEngine::RegisterDatabase(
  824.     LPCTSTR    pstrDatabase,
  825.     LPCTSTR    pstrDriver,
  826.     BOOL    bSilent,
  827.     LPCTSTR    pstrAttributes)
  828.     {
  829.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  830.  
  831.     DAOMFC_CALL(peng->RegisterDatabase(STB(pstrDatabase), STB(pstrDriver), BTB(bSilent), STB(pstrAttributes)));
  832.     }
  833.  
  834. VOID                CdbDBEngine::Idle(
  835.     LONG lOptions)    // = -1
  836.     {
  837.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  838.  
  839.     DAOMFC_CALL(peng->Idle(OLTV(lOptions)));
  840.     }
  841.  
  842. CdbDatabase            CdbDBEngine::OpenDatabase(
  843.     LPCTSTR        pstrName,
  844.     BOOL        bExclusive,         // 
  845.     BOOL        bReadOnly,            // = FALSE
  846.     LPCTSTR        pstrConnect)        // = NULL
  847.     {
  848.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  849.     DAODatabase *    pdb        = NULL;
  850.  
  851.     if (!peng)
  852.         return FALSE;
  853.  
  854.     DAOMFC_CALL(peng->OpenDatabase(STB(pstrName), BTV(bExclusive), BTV(bReadOnly), STV(pstrConnect), &pdb));
  855.  
  856.     return pdb;
  857.     }
  858.  
  859. CdbDatabase            CdbDBEngine::OpenDatabase(
  860.     LPCTSTR        pstrName,
  861.     LONG        lOptions,             // = 0L
  862.     BOOL        bReadOnly,            // = FALSE
  863.     LPCTSTR        pstrConnect)        // = NULL
  864.     {
  865.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  866.     DAODatabase *    pdb        = NULL;
  867.  
  868.     if (!peng)
  869.         return FALSE;
  870.  
  871.     DAOMFC_CALL(peng->OpenDatabase(STB(pstrName), OLTV(lOptions), BTV(bReadOnly), STV(pstrConnect), &pdb));
  872.  
  873.     return pdb;
  874.     }
  875.  
  876. CdbConnection            CdbDBEngine::OpenConnection(
  877.     LPCTSTR        pstrName,
  878.     LONG        lOption,        // = -1
  879.     BOOL        bReadOnly,        // = FALSE
  880.     LPCTSTR        pstrConnect)    // = NULL
  881.     {
  882.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  883.     DAOConnection *    pconn    = NULL;
  884.  
  885.     if (!peng)
  886.         return FALSE;
  887.  
  888.     DAOMFC_CALL(peng->OpenConnection(STB(pstrName), OLTV(lOption), BTV(bReadOnly), STV(pstrConnect), &pconn));
  889.  
  890.     return pconn;
  891.     }
  892.  
  893. /*****************************************************************************
  894. * CdbError
  895. */
  896. // Administration
  897. CONSTRUCTOR            CdbError::CdbError(
  898.     VOID)
  899.     {
  900.     }
  901.  
  902. CONSTRUCTOR            CdbError::CdbError(
  903.     DAOError *    perr,
  904.     BOOL        bAddRef)    // = FALSE
  905.     {
  906.     CdbOleObject::SetInterface((LPUNKNOWN)perr, bAddRef);
  907.     }
  908.  
  909. CONSTRUCTOR            CdbError::CdbError(
  910.     const CdbError &o)
  911.     {
  912.     SetInterface(o.GetInterface(TRUE));
  913.     }
  914.  
  915. CdbError &            CdbError::operator =(
  916.     const CdbError &o)
  917.     {
  918.     SetInterface(o.GetInterface(TRUE));
  919.     return *this;
  920.     }
  921.  
  922. VOID                CdbError::OnInterfaceChange(
  923.     VOID)
  924.     {
  925.     }
  926.  
  927. // Properties
  928. LONG                CdbError::GetNumber(
  929.     VOID)
  930.     {
  931.     LPROPGET(DAOError, get_Number);
  932.     }
  933.  
  934. CString                CdbError::GetSource(
  935.     VOID)
  936.     {
  937.     SPROPGET(DAOError, get_Source);
  938.     }
  939.  
  940. CString                CdbError::GetDescription(
  941.     VOID)
  942.     {
  943.     SPROPGET(DAOError, get_Description);
  944.     }
  945.  
  946. CString                CdbError::GetHelpFile(
  947.     VOID)
  948.     {
  949.     SPROPGET(DAOError, get_HelpFile);
  950.     }
  951.  
  952. LONG                CdbError::GetHelpContext(
  953.     VOID)
  954.     {
  955.     LPROPGET(DAOError, get_HelpContext);
  956.     }
  957.  
  958. /*****************************************************************************
  959. * CdbWorkspace
  960. */
  961. // Administration
  962. CONSTRUCTOR            CdbWorkspace::CdbWorkspace(
  963.     VOID)
  964.     {
  965.     }
  966.  
  967. CONSTRUCTOR            CdbWorkspace::CdbWorkspace(
  968.     DAOWorkspace *    pwrk,
  969.     BOOL            bAddRef)    // = FALSE
  970.     {
  971.     CdbOleObject::SetInterface((LPUNKNOWN)pwrk, bAddRef);
  972.     }
  973.  
  974. CONSTRUCTOR            CdbWorkspace::CdbWorkspace(
  975.     const CdbWorkspace &o)
  976.     {
  977.     CdbOleObject::SetInterface(o.GetInterface(TRUE));
  978.     }
  979.  
  980. CdbWorkspace &        CdbWorkspace::operator =(
  981.     const CdbWorkspace &o)
  982.     {
  983.     CdbOleObject::SetInterface(o.GetInterface(TRUE));
  984.     return *this;
  985.     }
  986.  
  987. VOID                CdbWorkspace::OnInterfaceChange(
  988.     VOID)
  989.     {
  990.     DAOWorkspace *        pwrk     = (DAOWorkspace *)GetInterface();
  991.     DAOProperties *        pprps    = NULL;
  992.     DAOUsers *            pusrs    = NULL;
  993.     DAOGroups *            pgrps    = NULL;
  994.     DAODatabases *        pdbs    = NULL;
  995.     DAOConnections *    pconn    = NULL;
  996.  
  997.     if (pwrk)
  998.         {
  999.         pwrk->get_Properties(&pprps);
  1000.         pwrk->get_Databases(&pdbs);
  1001.         pwrk->get_Connections(&pconn);
  1002.         pwrk->get_Users(&pusrs);
  1003.         pwrk->get_Groups(&pgrps);
  1004.         }
  1005.  
  1006.     Properties.SetInterface(pprps);
  1007.     Databases.SetInterface(pdbs);
  1008.     Connections.SetInterface(pconn);
  1009.     if(pwrk)
  1010.         Connections.SetWorkspace(pwrk);
  1011.     Users.SetInterface(pusrs);
  1012.     Groups.SetInterface(pgrps);
  1013.     }
  1014.  
  1015. // Properties
  1016. CString                CdbWorkspace::GetName(
  1017.     VOID)
  1018.     {
  1019.     SPROPGET(DAOWorkspace, get_Name);
  1020.     }
  1021.  
  1022. VOID                CdbWorkspace::SetName(
  1023.     LPCTSTR pstr)
  1024.     {
  1025.     SPROPSET(DAOWorkspace, put_Name, pstr);
  1026.     }
  1027.  
  1028. CString                CdbWorkspace::GetUserName(
  1029.     VOID)
  1030.     {
  1031.     SPROPGET(DAOWorkspace, get_UserName);
  1032.     }
  1033.  
  1034. BOOL                CdbWorkspace::GetIsolateODBCTrans(
  1035.     VOID)
  1036.     {
  1037.     BPROPGET(DAOWorkspace, get_IsolateODBCTrans);
  1038.     }
  1039.  
  1040. VOID                CdbWorkspace::SetIsolateODBCTrans(
  1041.     BOOL b)
  1042.     {
  1043.     BPROPSET(DAOWorkspace, put_IsolateODBCTrans, b);
  1044.     }
  1045.  
  1046. LONG                CdbWorkspace::GetType(
  1047.     VOID)
  1048.     {
  1049.     LPROPGET(DAOWorkspace, get_Type);
  1050.     }
  1051.  
  1052. LONG                CdbWorkspace::GetDefaultCursorDriver(
  1053.     VOID)
  1054.     {
  1055.     LPROPGET(DAOWorkspace, get_DefaultCursorDriver);
  1056.     }
  1057.  
  1058. VOID                CdbWorkspace::SetDefaultCursorDriver(
  1059.     LONG l)
  1060.     {
  1061.     LPROPSET(DAOWorkspace, put_DefaultCursorDriver, l);
  1062.     }
  1063.  
  1064. LONG                CdbWorkspace::GetLoginTimeout(
  1065.     VOID)
  1066.     {
  1067.     LPROPGET(DAOWorkspace, get_LoginTimeout);
  1068.     }
  1069.  
  1070. VOID                CdbWorkspace::SetLoginTimeout(
  1071.     LONG l)
  1072.     {
  1073.     LPROPSET(DAOWorkspace, put_LoginTimeout, l);
  1074.     }
  1075.  
  1076. // Methods
  1077. VOID                CdbWorkspace::BeginTrans(
  1078.     VOID)
  1079.     {
  1080.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  1081.  
  1082.     DAOMFC_CALL(pwrk->BeginTrans());
  1083.     }
  1084.  
  1085. VOID                CdbWorkspace::CommitTrans(
  1086.     long lOptions)            // = -1
  1087.     {
  1088.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  1089.  
  1090.     //DAO SDK functions default to -1 for longs, but since
  1091.     // this function is a strongly-typed optional, 0 is the
  1092.     // default. We need to convert this from -1 to 0
  1093.     if (lOptions == -1)
  1094.         lOptions = 0;
  1095.     DAOMFC_CALL(pwrk->CommitTrans(lOptions));
  1096.     }
  1097.  
  1098. VOID                CdbWorkspace::Close(
  1099.     VOID)
  1100.     {
  1101.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  1102.  
  1103.     DAOMFC_CALL(pwrk->Close());
  1104.     }
  1105.  
  1106. VOID                CdbWorkspace::Rollback(
  1107.     VOID)
  1108.     {
  1109.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  1110.  
  1111.     DAOMFC_CALL(pwrk->Rollback());
  1112.     }
  1113.  
  1114. CdbDatabase            CdbWorkspace::OpenDatabase(
  1115.     LPCTSTR    pstrName,
  1116.     BOOL    bExclusive,        // = FALSE
  1117.     BOOL    bReadOnly,        // = FALSE
  1118.     LPCTSTR    pstrConnect)    // = NULL
  1119.     {
  1120.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  1121.     DAODatabase *        pdb        = NULL;
  1122.  
  1123.     if (!pwrk)
  1124.         return (DAODatabase *)NULL;
  1125.  
  1126.     DAOMFC_CALL(pwrk->OpenDatabase(STB(pstrName), BTV(bExclusive), BTV(bReadOnly), STV(pstrConnect), &pdb));
  1127.  
  1128.     return pdb;
  1129.     }
  1130.  
  1131. CdbDatabase            CdbWorkspace::OpenDatabase(
  1132.     LPCTSTR        pstrName,
  1133.     LONG        lOptions,             // = -1L
  1134.     BOOL        bReadOnly,            // = FALSE
  1135.     LPCTSTR        pstrConnect)        // = NULL
  1136.     {
  1137.     DAOWorkspace *    pwrk    = (DAOWorkspace *)GetInterface();
  1138.     DAODatabase *    pdb        = NULL;
  1139.  
  1140.     if (!pwrk)
  1141.         return FALSE;
  1142.  
  1143.     DAOMFC_CALL(pwrk->OpenDatabase(STB(pstrName), OLTV(lOptions), BTV(bReadOnly), STV(pstrConnect), &pdb));
  1144.  
  1145.     return pdb;
  1146.     }
  1147.  
  1148. CdbConnection            CdbWorkspace::OpenConnection(
  1149.     LPCTSTR        pstrName,
  1150.     LONG        lOption,        // = -1
  1151.     BOOL        bReadOnly,        // = FALSE
  1152.     LPCTSTR        pstrConnect)    // = NULL
  1153.     {
  1154.     DAOWorkspace *    pwrk    = (DAOWorkspace *)GetInterface();
  1155.     DAOConnection *    pconn    = NULL;
  1156.  
  1157.     if (!pwrk)
  1158.         return FALSE;
  1159.  
  1160.     DAOMFC_CALL(pwrk->OpenConnection(STB(pstrName), OLTV(lOption), BTV(bReadOnly), STV(pstrConnect), &pconn));
  1161.  
  1162.     return pconn;
  1163.     }
  1164.  
  1165.  
  1166. CdbDatabase            CdbWorkspace::CreateDatabase(
  1167.     LPCTSTR    pstrName,
  1168.     LPCTSTR    pstrConnect,
  1169.     LONG    lOption)    // = -1
  1170.     {
  1171.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  1172.     DAODatabase *        pdb        = NULL;
  1173.  
  1174.     if (!pwrk)
  1175.         return (DAODatabase *)NULL;
  1176.  
  1177.     DAOMFC_CALL(pwrk->CreateDatabase(STB(pstrName), STB(pstrConnect), OLTV(lOption), &pdb));
  1178.  
  1179.     return pdb;
  1180.     }
  1181.  
  1182. CdbUser                CdbWorkspace::CreateUser(
  1183.     LPCTSTR pstrName,        // = NULL
  1184.     LPCTSTR pstrPID,        // = NULL
  1185.     LPCTSTR pstrPassword)    // = NULL
  1186.     {
  1187.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  1188.     DAOUser *            pusr    = NULL;
  1189.  
  1190.     if (!pwrk)
  1191.         return (DAOUser *)NULL;
  1192.  
  1193.     DAOMFC_CALL(pwrk->CreateUser(STV(pstrName), STV(pstrPID), STV(pstrPassword), &pusr));
  1194.  
  1195.     return pusr;
  1196.     }
  1197.  
  1198. CdbGroup            CdbWorkspace::CreateGroup(
  1199.     LPCTSTR pstrName,    // = NULL
  1200.     LPCTSTR pstrPID)    // = NULL
  1201.     {
  1202.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  1203.     DAOGroup *            pgrp    = NULL;
  1204.  
  1205.     if (!pwrk)
  1206.         return (DAOGroup *)NULL;
  1207.  
  1208.     DAOMFC_CALL(pwrk->CreateGroup(STV(pstrName), STV(pstrPID), &pgrp));
  1209.  
  1210.     return pgrp;
  1211.     }
  1212.  
  1213. /*****************************************************************************
  1214. * CdbDatabase
  1215. */
  1216. // Administration
  1217. CONSTRUCTOR            CdbDatabase::CdbDatabase(
  1218.     VOID)
  1219.     {
  1220.     }
  1221.  
  1222. CONSTRUCTOR            CdbDatabase::CdbDatabase(
  1223.     DAODatabase *    pdb,
  1224.     BOOL            bAddRef)    // = FALSE
  1225.     {
  1226.     CdbOleObject::SetInterface((LPUNKNOWN)pdb, bAddRef);
  1227.     }
  1228.  
  1229. CONSTRUCTOR            CdbDatabase::CdbDatabase(
  1230.     const CdbDatabase &o)
  1231.     {
  1232.     SetInterface(o.GetInterface(TRUE));
  1233.     }
  1234.  
  1235. CdbDatabase &        CdbDatabase::operator =(
  1236.     const CdbDatabase &o)
  1237.     {
  1238.     SetInterface(o.GetInterface(TRUE));
  1239.     return *this;
  1240.     }
  1241.  
  1242. VOID                CdbDatabase::OnInterfaceChange(
  1243.     VOID)
  1244.     {
  1245.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1246.     DAOProperties *    pprps    = NULL;
  1247.     DAOTableDefs *    ptds    = NULL;
  1248.     DAOQueryDefs *    pqds    = NULL;
  1249.     DAORelations *    prls    = NULL;
  1250.     DAOContainers *    pcts    = NULL;
  1251.     DAORecordsets *    prss    = NULL;
  1252.  
  1253.     if (pdb)
  1254.         {
  1255.         pdb->get_Properties(&pprps);
  1256.         pdb->get_TableDefs(&ptds);
  1257.         pdb->get_QueryDefs(&pqds);
  1258.         pdb->get_Relations(&prls);
  1259.         pdb->get_Containers(&pcts);
  1260.         pdb->get_Recordsets(&prss);
  1261.         }
  1262.  
  1263.     Properties.SetInterface(pprps);
  1264.     TableDefs.SetInterface(ptds);
  1265.     QueryDefs.SetInterface(pqds);
  1266.     Relations.SetInterface(prls);
  1267.     Containers.SetInterface(pcts);
  1268.     Recordsets.SetInterface(prss);
  1269.     }
  1270.  
  1271. // Properties
  1272. LONG                CdbDatabase::GetCollatingOrder(
  1273.     VOID)
  1274.     {
  1275.     LPROPGET(DAODatabase, get_CollatingOrder);
  1276.     }
  1277.  
  1278. CString                CdbDatabase::GetConnect(
  1279.     VOID)
  1280.     {
  1281.     SPROPGET(DAODatabase, get_Connect);
  1282.     }
  1283.  
  1284. VOID                CdbDatabase::SetConnect(
  1285.     LPCTSTR    pstr)
  1286.     {
  1287.     SPROPSET(DAODatabase, put_Connect, pstr);
  1288.     }
  1289.  
  1290. CString                CdbDatabase::GetName(
  1291.     VOID)
  1292.     {
  1293.     SPROPGET(DAODatabase, get_Name);
  1294.     }
  1295.  
  1296. SHORT                CdbDatabase::GetQueryTimeout(
  1297.     VOID)
  1298.     {
  1299.     WPROPGET(DAODatabase, get_QueryTimeout);
  1300.     }
  1301.  
  1302. VOID                CdbDatabase::SetQueryTimeout(
  1303.     SHORT s)
  1304.     {
  1305.     WPROPSET(DAODatabase, put_QueryTimeout, s);
  1306.     }
  1307.  
  1308. BOOL                CdbDatabase::GetTransactions(
  1309.     VOID)
  1310.     {
  1311.     BPROPGET(DAODatabase, get_Transactions);
  1312.     }
  1313.  
  1314. BOOL                CdbDatabase::GetUpdatable(
  1315.     VOID)
  1316.     {
  1317.     BPROPGET(DAODatabase, get_Updatable);
  1318.     }
  1319.  
  1320. CString                CdbDatabase::GetVersion(
  1321.     VOID)
  1322.     {
  1323.     SPROPGET(DAODatabase, get_Version);
  1324.     }
  1325.  
  1326. LONG                CdbDatabase::GetRecordsAffected(
  1327.     VOID)
  1328.     {
  1329.     LPROPGET(DAODatabase, get_RecordsAffected);
  1330.     }
  1331.  
  1332. CdbConnection        CdbDatabase::GetConnection(
  1333.     VOID)
  1334.     {
  1335.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1336.     DAOConnection *    pconn    = NULL;
  1337.  
  1338.     if (!pdb)
  1339.         return FALSE;
  1340.  
  1341.     DAOMFC_CALL(pdb->get_Connection(&pconn));
  1342.  
  1343.     return pconn;
  1344.     }
  1345. CString                CdbDatabase::GetReplicaID(
  1346.     VOID)
  1347.     {
  1348.     SPROPGET(DAODatabase, get_ReplicaID);
  1349.     }
  1350.  
  1351. CString                CdbDatabase::GetDesignMasterID(
  1352.     VOID)
  1353.     {
  1354.     SPROPGET(DAODatabase, get_DesignMasterID);
  1355.     }
  1356.  
  1357. VOID                CdbDatabase::SetDesignMasterID(
  1358.     LPCTSTR    pstr)
  1359.     {
  1360.     SPROPSET(DAODatabase, put_DesignMasterID, pstr);
  1361.     }
  1362.  
  1363. // Methods
  1364. VOID                CdbDatabase::Close(
  1365.     VOID)
  1366.     {
  1367.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1368.  
  1369.     DAOMFC_CALL(pdb->Close());
  1370.     }
  1371.  
  1372. VOID                CdbDatabase::Execute(
  1373.     LPCTSTR    pstrQuery,
  1374.     LONG    lOption)    // = -1
  1375.     {
  1376.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1377.  
  1378.     DAOMFC_CALL(pdb->Execute(STB(pstrQuery), OLTV(lOption)));
  1379.     }
  1380.  
  1381. CdbRecordset        CdbDatabase::OpenRecordset(
  1382.     LPCTSTR    pstrName,
  1383.     LONG    lType,        // = -1
  1384.     LONG    lOptions,   // = -1
  1385.     LONG    lLockEdit)    // = -1
  1386.     {
  1387.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1388.     DAORecordset *    prs        = NULL;
  1389.  
  1390.     if (!pdb)
  1391.         return (DAORecordset *)NULL;
  1392.  
  1393.     DAOMFC_CALL(pdb->OpenRecordset(STB(pstrName), OLTV(lType), OLTV(lOptions), OLTV(lLockEdit), &prs));
  1394.  
  1395.     return prs;
  1396.     }
  1397.  
  1398. CdbProperty            CdbDatabase::CreateProperty(
  1399.     LPCTSTR        pstrName,    // = NULL
  1400.     LONG        lType,        // = -1
  1401.     LPVARIANT    pvValue,    // = NULL
  1402.     BOOL        bDDL)        // = FALSE
  1403.     {
  1404.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1405.     DAOProperty *    pprp    = NULL;
  1406.  
  1407.     if (!pdb)
  1408.         return (DAOProperty *)NULL;
  1409.  
  1410.     DAOMFC_CALL(pdb->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
  1411.  
  1412.     return pprp;
  1413.     }
  1414.  
  1415. CdbRelation            CdbDatabase::CreateRelation(
  1416.     LPCTSTR    pstrName,        // = NULL
  1417.     LPCTSTR    pstrTable,        // = NULL
  1418.     LPCTSTR    pstrForiegn,    // = NULL
  1419.     LONG    lAttributes)    // = -1
  1420.     {
  1421.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1422.     DAORelation *    prl        = NULL;
  1423.  
  1424.     if (!pdb)
  1425.         return (DAORelation *)NULL;
  1426.  
  1427.     DAOMFC_CALL(pdb->CreateRelation(STV(pstrName), STV(pstrTable), STV(pstrForiegn), OLTV(lAttributes), &prl));
  1428.  
  1429.     return prl;
  1430.     }
  1431.  
  1432. CdbTableDef            CdbDatabase::CreateTableDef(
  1433.     LPCTSTR    pstrName,        // = NULL
  1434.     LONG    lAttributes,    // = -1
  1435.     LPCTSTR    pstrSource,        // = NULL
  1436.     LPCTSTR    pstrConnect)    // = NULL
  1437.     {
  1438.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1439.     DAOTableDef *    ptd        = NULL;
  1440.  
  1441.     if (!pdb)
  1442.         return (DAOTableDef *)NULL;
  1443.  
  1444.     DAOMFC_CALL(pdb->CreateTableDef(STV(pstrName), OLTV(lAttributes), STV(pstrSource), STV(pstrConnect), &ptd));
  1445.  
  1446.     return ptd;
  1447.     }
  1448.  
  1449. CdbQueryDef            CdbDatabase::CreateQueryDef(
  1450.     LPCTSTR pstrName,    // = NULL
  1451.     LPCTSTR pstrSQL)    // = NULL
  1452.     {
  1453.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1454.     DAOQueryDef *    pqd        = NULL;
  1455.  
  1456.     if (!pdb)
  1457.         return (DAOQueryDef *)NULL;
  1458.  
  1459.     DAOMFC_CALL(pdb->CreateQueryDef(STV(pstrName), STV(pstrSQL), &pqd));
  1460.  
  1461.     return pqd;
  1462.     }
  1463.  
  1464. VOID                CdbDatabase::NewPassword(
  1465.     LPCTSTR pstrOld, 
  1466.     LPCTSTR pstrNew)
  1467.     {
  1468.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1469.  
  1470.     if (!pdb)
  1471.         return;
  1472.  
  1473.     DAOMFC_CALL(pdb->NewPassword(STB(pstrOld), STB(pstrNew)));
  1474.     }
  1475.  
  1476. VOID                CdbDatabase::Synchronize(
  1477.     LPCTSTR pstrReplica, 
  1478.     LONG lType)         // = -1
  1479.     {
  1480.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1481.  
  1482.     if (!pdb)
  1483.         return;
  1484.  
  1485.     DAOMFC_CALL(pdb->Synchronize(STB(pstrReplica), OLTV(lType)));
  1486.     }
  1487.  
  1488. VOID                CdbDatabase::MakeReplica(
  1489.     LPCTSTR pstrPath, 
  1490.     LPCTSTR pstrDescription, 
  1491.     LONG lOptions)            // = -1
  1492.     {
  1493.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1494.  
  1495.     if (!pdb)
  1496.         return;
  1497.  
  1498.     DAOMFC_CALL(pdb->MakeReplica(STB(pstrPath), STB(pstrDescription), OLTV(lOptions)));
  1499.     }
  1500.  
  1501. VOID                CdbDatabase::PopulatePartial(
  1502.     LPCTSTR pstrDbPathName)
  1503.     {
  1504.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1505.  
  1506.     if (!pdb)
  1507.         return;
  1508.  
  1509.     DAOMFC_CALL(pdb->PopulatePartial(STB(pstrDbPathName)));
  1510.     }
  1511.  
  1512.  
  1513. /*****************************************************************************
  1514. * CdbConnection
  1515. */
  1516. // Administration
  1517. CONSTRUCTOR            CdbConnection::CdbConnection(
  1518.     VOID)
  1519.     {
  1520.     }
  1521.  
  1522. CONSTRUCTOR            CdbConnection::CdbConnection(
  1523.     DAOConnection *    pconn,
  1524.     BOOL            bAddRef)    // = FALSE
  1525.     {
  1526.     CdbOleObject::SetInterface((LPUNKNOWN)pconn, bAddRef);
  1527.     }
  1528.  
  1529. CONSTRUCTOR            CdbConnection::CdbConnection(
  1530.     const CdbConnection &o)
  1531.     {
  1532.     SetInterface(o.GetInterface(TRUE));
  1533.     }
  1534.  
  1535. CdbConnection &        CdbConnection::operator =(
  1536.     const CdbConnection &o)
  1537.     {
  1538.     SetInterface(o.GetInterface(TRUE));
  1539.     return *this;
  1540.     }
  1541.  
  1542. VOID                CdbConnection::OnInterfaceChange(
  1543.     VOID)
  1544.     {
  1545.     DAOConnection *    pconn        = (DAOConnection *)GetInterface();
  1546.     DAOQueryDefs *    pqds    = NULL;
  1547.     DAORecordsets *    prss    = NULL;
  1548.  
  1549.     if (pconn)
  1550.         {
  1551.         pconn->get_QueryDefs(&pqds);
  1552.         pconn->get_Recordsets(&prss);
  1553.         }
  1554.  
  1555.     QueryDefs.SetInterface(pqds);
  1556.     Recordsets.SetInterface(prss);
  1557.     }
  1558.  
  1559. // Properties
  1560. CString                CdbConnection::GetConnect(
  1561.     VOID)
  1562.     {
  1563.     SPROPGET(DAOConnection, get_Connect);
  1564.     }
  1565.  
  1566. CString                CdbConnection::GetName(
  1567.     VOID)
  1568.     {
  1569.     SPROPGET(DAOConnection, get_Name);
  1570.     }
  1571.  
  1572. CdbDatabase            CdbConnection::GetDatabase(
  1573.     VOID)
  1574.     {
  1575.     DAOConnection *    pconn        = (DAOConnection *)GetInterface();
  1576.     DAODatabase *    pdb        = NULL;
  1577.  
  1578.     if (!pconn)
  1579.         return (DAODatabase *)NULL;
  1580.  
  1581.     DAOMFC_CALL(pconn->get_Database(&pdb));
  1582.  
  1583.     return pdb;
  1584.     }
  1585.  
  1586. SHORT                CdbConnection::GetQueryTimeout(
  1587.     VOID)
  1588.     {
  1589.     WPROPGET(DAOConnection, get_QueryTimeout);
  1590.     }
  1591.  
  1592. VOID                CdbConnection::SetQueryTimeout(
  1593.     SHORT s)
  1594.     {
  1595.     WPROPSET(DAOConnection, put_QueryTimeout, s);
  1596.     }
  1597.  
  1598. BOOL                CdbConnection::GetUpdatable(
  1599.     VOID)
  1600.     {
  1601.     BPROPGET(DAOConnection, get_Updatable);
  1602.     }
  1603.  
  1604.  
  1605. LONG                CdbConnection::GetRecordsAffected(
  1606.     VOID)
  1607.     {
  1608.     LPROPGET(DAOConnection, get_RecordsAffected);
  1609.     }
  1610.  
  1611. BOOL                CdbConnection::GetStillExecuting(
  1612.     VOID)
  1613.     {
  1614.     BPROPGET(DAOConnection, get_StillExecuting);
  1615.     }
  1616.  
  1617. BOOL                CdbConnection::GetTransactions(
  1618.     VOID)
  1619.     {
  1620.     BPROPGET(DAOConnection, get_Transactions);
  1621.     }
  1622.  
  1623.  
  1624. // Methods
  1625. VOID                CdbConnection::Cancel(
  1626.     VOID)
  1627.     {
  1628.     DAOConnection *    pconn        = (DAOConnection *)GetInterface();
  1629.  
  1630.     DAOMFC_CALL(pconn->Cancel());
  1631.     }
  1632.  
  1633. VOID                CdbConnection::Close(
  1634.     VOID)
  1635.     {
  1636.     DAOConnection *    pconn        = (DAOConnection *)GetInterface();
  1637.  
  1638.     DAOMFC_CALL(pconn->Close());
  1639.     }
  1640.  
  1641. VOID                CdbConnection::Execute(
  1642.     LPCTSTR    pstrQuery,
  1643.     LONG    lOption)    // = -1
  1644.     {
  1645.     DAOConnection *    pconn        = (DAOConnection *)GetInterface();
  1646.  
  1647.     DAOMFC_CALL(pconn->Execute(STB(pstrQuery), OLTV(lOption)));
  1648.     }
  1649.  
  1650. CdbRecordset        CdbConnection::OpenRecordset(
  1651.     LPCTSTR    pstrName,
  1652.     LONG    lType,        // = -1
  1653.     LONG    lOptions,    // = -1
  1654.     LONG    lLockEdit)  // = -1
  1655.     {
  1656.     DAOConnection *    pconn        = (DAOConnection *)GetInterface();
  1657.     DAORecordset *    prs        = NULL;
  1658.  
  1659.     if (!pconn)
  1660.         return (DAORecordset *)NULL;
  1661.  
  1662.     DAOMFC_CALL(pconn->OpenRecordset(STB(pstrName), OLTV(lType), OLTV(lOptions), OLTV(lLockEdit), &prs));
  1663.  
  1664.     return prs;
  1665.     }
  1666.  
  1667. CdbQueryDef            CdbConnection::CreateQueryDef(
  1668.     LPCTSTR pstrName,    // = NULL
  1669.     LPCTSTR pstrSQL)    // = NULL
  1670.     {
  1671.     DAOConnection *    pconn        = (DAOConnection *)GetInterface();
  1672.     DAOQueryDef *    pqd        = NULL;
  1673.  
  1674.     if (!pconn)
  1675.         return (DAOQueryDef *)NULL;
  1676.  
  1677.     DAOMFC_CALL(pconn->CreateQueryDef(STV(pstrName), STV(pstrSQL), &pqd));
  1678.  
  1679.     return pqd;
  1680.     }
  1681.  
  1682. /*****************************************************************************
  1683. * CdbRecordset
  1684. */
  1685. // Administration
  1686. CONSTRUCTOR            CdbRecordset::CdbRecordset(
  1687.     VOID)
  1688.     {
  1689.     }
  1690.  
  1691. CONSTRUCTOR            CdbRecordset::CdbRecordset(
  1692.     DAORecordset *    prs,
  1693.     BOOL             bAddRef)    // = FALSE
  1694.     {
  1695.     CdbOleObject::SetInterface((LPUNKNOWN)prs, bAddRef);
  1696.     }
  1697.  
  1698. CONSTRUCTOR            CdbRecordset::CdbRecordset(
  1699.     const CdbRecordset &o)
  1700.     {
  1701.     SetInterface(o.GetInterface(TRUE));
  1702.     }
  1703.  
  1704. CdbRecordset &        CdbRecordset::operator =(
  1705.     const CdbRecordset &o)
  1706.     {
  1707.     SetInterface(o.GetInterface(TRUE));
  1708.     return *this;
  1709.     }
  1710.  
  1711. VOID                CdbRecordset::OnInterfaceChange(
  1712.     VOID)
  1713.     {
  1714.     DAORecordset *        prs        = (DAORecordset *)GetInterface();
  1715.     DAOProperties *        pprps    = NULL;
  1716.     DAOFields *            pflds    = NULL;
  1717.     if (prs)
  1718.         {
  1719.         prs->get_Properties(&pprps);
  1720.         prs->get_Fields(&pflds);
  1721.         }
  1722.  
  1723.     Properties.SetInterface(pprps);
  1724.     Fields.SetInterface(pflds);
  1725.     }
  1726.  
  1727. VOID                CdbRecordset::SetGetRowsExInt(
  1728.     VOID)
  1729.     {
  1730.     DAORecordset *        prs        = (DAORecordset *)GetInterface();
  1731.     ICDAORecordset *    pGetRows = NULL;
  1732.     if (prs)
  1733.         {
  1734.         prs->QueryInterface(IID_ICDAORecordset, (void **)&pGetRows);
  1735.         }
  1736.     m_GetRowsInt.SetInterface(pGetRows);
  1737.     }
  1738.  
  1739. // Properties
  1740. BOOL                CdbRecordset::GetBOF(
  1741.     VOID)
  1742.     {
  1743.     BPROPGET(DAORecordset, get_BOF);
  1744.     }
  1745.  
  1746. CdbBookmark            CdbRecordset::GetBookmark(
  1747.     VOID)
  1748.     {
  1749.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1750.     LPSAFEARRAY        psa = NULL;
  1751.  
  1752.     if (!prs)
  1753.         return (LPSAFEARRAY)NULL;
  1754.  
  1755.     DAOMFC_CALL(prs->get_Bookmark(&psa));
  1756.  
  1757.     return psa;
  1758.     }
  1759.  
  1760. VOID                CdbRecordset::SetBookmark(
  1761.     class CdbBookmark cbm)
  1762.     {
  1763.     LPSAFEARRAY        psa = (LPSAFEARRAY)cbm;
  1764.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1765.  
  1766.     DAOMFC_CALL(prs->put_Bookmark(&psa));
  1767.     }
  1768.  
  1769. BOOL                CdbRecordset::GetBookmarkable(
  1770.     VOID)
  1771.     {
  1772.     BPROPGET(DAORecordset, get_Bookmarkable);
  1773.     }
  1774.  
  1775. COleDateTime            CdbRecordset::GetDateCreated(
  1776.     VOID)
  1777.     {
  1778.     DPROPGET(DAORecordset, get_DateCreated);
  1779.     }
  1780.  
  1781. COleDateTime            CdbRecordset::GetLastUpdated(
  1782.     VOID)
  1783.     {
  1784.     DPROPGET(DAORecordset, get_LastUpdated);
  1785.     }
  1786.  
  1787. BOOL                CdbRecordset::GetEOF(
  1788.     VOID)
  1789.     {
  1790.     BPROPGET(DAORecordset, get_EOF);
  1791.     }
  1792.  
  1793.  
  1794. CString                CdbRecordset::GetFilter(
  1795.     VOID)
  1796.     {
  1797.     SPROPGET(DAORecordset, get_Filter);
  1798.     }
  1799.  
  1800. VOID                CdbRecordset::SetFilter(
  1801.     LPCTSTR pstr)
  1802.     {
  1803.     SPROPSET(DAORecordset, put_Filter, pstr);
  1804.     }
  1805.  
  1806. CString                CdbRecordset::GetIndex(
  1807.     VOID)
  1808.     {
  1809.     SPROPGET(DAORecordset, get_Index);
  1810.     }
  1811.  
  1812. VOID                CdbRecordset::SetIndex(
  1813.     LPCTSTR pstr)
  1814.     {
  1815.     SPROPSET(DAORecordset, put_Index, pstr);
  1816.     }
  1817.  
  1818. CdbBookmark            CdbRecordset::GetLastModified(
  1819.     VOID)
  1820.     {
  1821.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1822.     LPSAFEARRAY        psa;
  1823.  
  1824.     if (!prs)
  1825.         return (LPSAFEARRAY)NULL;
  1826.  
  1827.     DAOMFC_CALL(prs->get_LastModified(&psa));
  1828.  
  1829.     return psa;
  1830.     }
  1831.  
  1832. BOOL                CdbRecordset::GetLockEdits(
  1833.     VOID)
  1834.     {
  1835.     BPROPGET(DAORecordset, get_LockEdits);
  1836.     }
  1837.  
  1838. VOID                CdbRecordset::SetLockEdits(
  1839.     BOOL b)
  1840.     {
  1841.     BPROPSET(DAORecordset, put_LockEdits, b);
  1842.     }
  1843.  
  1844. CString                CdbRecordset::GetName(
  1845.     VOID)
  1846.     {
  1847.     SPROPGET(DAORecordset, get_Name);
  1848.     }
  1849.  
  1850. BOOL                CdbRecordset::GetNoMatch(
  1851.     VOID)
  1852.     {
  1853.     BPROPGET(DAORecordset, get_NoMatch);
  1854.     }
  1855.  
  1856. CString                CdbRecordset::GetSort(
  1857.     VOID)
  1858.     {
  1859.     SPROPGET(DAORecordset, get_Sort);
  1860.     }
  1861.  
  1862. VOID                CdbRecordset::SetSort(
  1863.     LPCTSTR pstr)
  1864.     {
  1865.     SPROPSET(DAORecordset, put_Sort, pstr);
  1866.     }
  1867.  
  1868. BOOL                CdbRecordset::GetTransactions(
  1869.     VOID)
  1870.     {
  1871.     BPROPGET(DAORecordset, get_Transactions);
  1872.     }
  1873.  
  1874. SHORT                CdbRecordset::GetType(
  1875.     VOID)
  1876.     {
  1877.     WPROPGET(DAORecordset, get_Type);
  1878.     }
  1879.  
  1880. LONG                CdbRecordset::GetRecordCount(
  1881.     VOID)
  1882.     {
  1883.     LPROPGET(DAORecordset, get_RecordCount);
  1884.     }
  1885.  
  1886. BOOL                CdbRecordset::GetUpdatable(
  1887.     VOID)
  1888.     {
  1889.     BPROPGET(DAORecordset, get_Updatable);
  1890.     }
  1891.  
  1892. BOOL                CdbRecordset::GetRestartable(
  1893.     VOID)
  1894.     {
  1895.     BPROPGET(DAORecordset, get_Restartable);
  1896.     }
  1897.  
  1898. CString                CdbRecordset::GetValidationText(
  1899.     VOID)
  1900.     {
  1901.     SPROPGET(DAORecordset, get_ValidationText);
  1902.     }
  1903.  
  1904. CString                CdbRecordset::GetValidationRule(
  1905.     VOID)
  1906.     {
  1907.     SPROPGET(DAORecordset, get_ValidationRule);
  1908.     }
  1909.  
  1910. CdbBookmark            CdbRecordset::GetCacheStart(
  1911.     VOID)
  1912.     {
  1913.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1914.     LPSAFEARRAY        psa;
  1915.  
  1916.     if (!prs)
  1917.         return (LPSAFEARRAY)NULL;
  1918.  
  1919.     DAOMFC_CALL(prs->get_CacheStart(&psa));
  1920.  
  1921.     return psa;
  1922.     }
  1923.  
  1924. VOID                CdbRecordset::SetCacheStart(
  1925.     CdbBookmark &bm)
  1926.     {
  1927.     LPSAFEARRAY        psa = (LPSAFEARRAY)bm;
  1928.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1929.  
  1930.     DAOMFC_CALL(prs->put_CacheStart(&psa));
  1931.     }
  1932.  
  1933. LONG                CdbRecordset::GetCacheSize(
  1934.     VOID)
  1935.     {
  1936.     LPROPGET(DAORecordset, get_CacheSize);
  1937.     }
  1938.  
  1939. VOID                CdbRecordset::SetCacheSize(
  1940.     LONG l)
  1941.     {
  1942.     LPROPSET(DAORecordset, put_CacheSize, l);
  1943.     }
  1944.  
  1945. FLOAT                CdbRecordset::GetPercentPosition(
  1946.     VOID)
  1947.     {
  1948.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1949.     FLOAT            f    = (FLOAT)0.0;
  1950.  
  1951.     if (!prs)
  1952.         return (FLOAT)0.0;
  1953.  
  1954.     DAOMFC_CALL(prs->get_PercentPosition(&f));
  1955.  
  1956.     return f;
  1957.     }
  1958.  
  1959. VOID                CdbRecordset::SetPercentPosition(
  1960.     FLOAT f)
  1961.     {
  1962.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1963.  
  1964.     DAOMFC_CALL(prs->put_PercentPosition(f));
  1965.     }
  1966.  
  1967. LONG                CdbRecordset::GetAbsolutePosition(
  1968.     VOID)
  1969.     {
  1970.     LPROPGET(DAORecordset, get_AbsolutePosition);
  1971.     }
  1972.     
  1973. VOID                CdbRecordset::SetAbsolutePosition(
  1974.     LONG l)
  1975.     {
  1976.     LPROPSET(DAORecordset, put_AbsolutePosition, l);
  1977.     }
  1978.  
  1979. SHORT                CdbRecordset::GetEditMode(
  1980.     VOID)
  1981.     {
  1982.     WPROPGET(DAORecordset, get_EditMode);
  1983.     }
  1984.     
  1985. LONG                CdbRecordset::GetUpdateOptions(
  1986.     VOID)
  1987.     {
  1988.     LPROPGET(DAORecordset, get_UpdateOptions);
  1989.     }
  1990.  
  1991. VOID                CdbRecordset::SetUpdateOptions(
  1992.     LONG l)
  1993.     {
  1994.     LPROPSET(DAORecordset, put_UpdateOptions, l);
  1995.     }
  1996.  
  1997. SHORT                 CdbRecordset::GetRecordStatus(
  1998.     VOID)
  1999.     {
  2000.     WPROPGET(DAORecordset, get_RecordStatus);
  2001.     }
  2002.     
  2003. BOOL                CdbRecordset::GetStillExecuting(
  2004.     VOID)
  2005.     {
  2006.     BPROPGET(DAORecordset, get_StillExecuting);
  2007.     }
  2008.  
  2009. LONG                CdbRecordset::GetBatchSize(
  2010.     VOID)
  2011.     {
  2012.     LPROPGET(DAORecordset, get_BatchSize);
  2013.     }
  2014.  
  2015. VOID                CdbRecordset::SetBatchSize(
  2016.     LONG l)
  2017.     {
  2018.     LPROPSET(DAORecordset, put_BatchSize, l);
  2019.     }
  2020.  
  2021. LONG                CdbRecordset::GetBatchCollisionCount(
  2022.     VOID)
  2023.     {
  2024.     LPROPGET(DAORecordset, get_BatchCollisionCount);
  2025.     }
  2026.  
  2027. COleVariant            CdbRecordset::GetBatchCollisions(
  2028.     VOID)
  2029.     {
  2030.     VPROPGET(DAORecordset, get_BatchCollisions);
  2031.     }
  2032.  
  2033. CdbConnection        CdbRecordset::GetConnection(
  2034.     VOID)
  2035.     {
  2036.     DAORecordset *    prs        = (DAORecordset *)GetInterface();
  2037.     DAOConnection *    pconn    = NULL;
  2038.  
  2039.     if (!prs)
  2040.         return FALSE;
  2041.  
  2042.     DAOMFC_CALL(prs->get_Connection(&pconn));
  2043.  
  2044.     return pconn;
  2045.     }
  2046.  
  2047. // Methods
  2048. VOID                CdbRecordset::CancelUpdate(
  2049.     short sType) //dbUpdateRegular)
  2050.     {
  2051.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2052.  
  2053.     DAOMFC_CALL(prs->CancelUpdate(sType));
  2054.     }
  2055.  
  2056. VOID                CdbRecordset::AddNew(
  2057.     VOID)
  2058.     {
  2059.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2060.  
  2061.     DAOMFC_CALL(prs->AddNew());
  2062.     }
  2063.  
  2064. VOID                CdbRecordset::Close(
  2065.     VOID)
  2066.     {
  2067.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2068.  
  2069.     DAOMFC_CALL(prs->Close());
  2070.     }
  2071.  
  2072. CdbRecordset        CdbRecordset::OpenRecordset(
  2073.     LONG    lType,        // = -1
  2074.     LONG     lOption)    // = -1
  2075.     {
  2076.     DAORecordset *    prs        = (DAORecordset *)GetInterface();
  2077.     DAORecordset *    prsNew    = NULL;
  2078.  
  2079.     if (!prs)
  2080.         return (DAORecordset *)NULL;
  2081.  
  2082.     DAOMFC_CALL(prs->OpenRecordset(SHTV(lType), OLTV(lOption), &prsNew));
  2083.  
  2084.     return prsNew;
  2085.     }
  2086.  
  2087. VOID                CdbRecordset::Delete(
  2088.     VOID)
  2089.     {
  2090.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2091.  
  2092.     DAOMFC_CALL(prs->Delete());
  2093.     }
  2094.  
  2095. VOID                CdbRecordset::Edit(
  2096.     VOID)
  2097.     {
  2098.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2099.  
  2100.     DAOMFC_CALL(prs->Edit());
  2101.     }
  2102.  
  2103. VOID                CdbRecordset::FindFirst(
  2104.     LPCTSTR pstrCriteria)
  2105.     {
  2106.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2107.  
  2108.     DAOMFC_CALL(prs->FindFirst(STB(pstrCriteria)));
  2109.     }
  2110.  
  2111. VOID                CdbRecordset::FindLast(
  2112.     LPCTSTR pstrCriteria)
  2113.     {
  2114.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2115.  
  2116.     DAOMFC_CALL(prs->FindLast(STB(pstrCriteria)));
  2117.     }
  2118.  
  2119. VOID                CdbRecordset::FindNext(
  2120.     LPCTSTR pstrCriteria)
  2121.     {
  2122.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2123.  
  2124.     DAOMFC_CALL(prs->FindNext(STB(pstrCriteria)));
  2125.     }
  2126.  
  2127. VOID                CdbRecordset::FindPrevious(
  2128.     LPCTSTR pstrCriteria)
  2129.     {
  2130.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2131.  
  2132.     DAOMFC_CALL(prs->FindPrevious(STB(pstrCriteria)));
  2133.     }
  2134.  
  2135. VOID                CdbRecordset::MoveFirst(
  2136.     VOID)
  2137.     {
  2138.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2139.  
  2140.     DAOMFC_CALL(prs->MoveFirst());
  2141.     }
  2142.  
  2143. VOID                CdbRecordset::MoveLast(
  2144.     LONG lOptions) // = -1
  2145.     {
  2146.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2147.  
  2148.     //DAO SDK functions default to -1 for longs, but since
  2149.     // this function is a strongly-typed optional, 0 is the
  2150.     // default. We need to convert this from -1 to 0
  2151.     if (lOptions == -1)
  2152.         lOptions = 0;
  2153.     DAOMFC_CALL(prs->MoveLast(lOptions));
  2154.     }
  2155.  
  2156. VOID                CdbRecordset::MoveNext(
  2157.     VOID)
  2158.     {
  2159.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2160.  
  2161.     DAOMFC_CALL(prs->MoveNext());
  2162.     }
  2163.  
  2164. VOID                CdbRecordset::MovePrevious(
  2165.     VOID)
  2166.     {
  2167.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2168.  
  2169.     DAOMFC_CALL(prs->MovePrevious());
  2170.     }
  2171.  
  2172.  
  2173. VOID                CdbRecordset::Seek(
  2174.     LPCTSTR    pstrComparison,
  2175.     LONG lNumFields,
  2176.     COleVariant    cKey,
  2177.     ...)
  2178.     {
  2179.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2180.     COleVariant *    lpV;
  2181.     va_list            valist;
  2182.     CdbVariant        v[13];
  2183.     LONG            lIndex;
  2184.  
  2185.     ASSERT(lNumFields <= DAO_MAXSEEKFIELDS && lNumFields > 0);
  2186.  
  2187.     lpV = &cKey;
  2188.     va_start(valist, cKey);
  2189.  
  2190.     v[0] = *lpV;
  2191.     for(lIndex = 1; lIndex < lNumFields && (lpV = &(va_arg(valist, COleVariant))) != 0; lIndex++ )
  2192.         {
  2193.         v[lIndex] = *lpV;
  2194.         }
  2195.  
  2196.     va_end(valist);
  2197.  
  2198.     DAOMFC_CALL(prs->Seek(STB(pstrComparison), v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12]));
  2199.     }
  2200.  
  2201. VOID                CdbRecordset::Update(
  2202.     short            sType,    // = dbUpdateRegular
  2203.     VARIANT_BOOL    bForce) // = FALSE
  2204.     {
  2205.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  2206.  
  2207.     DAOMFC_CALL(prs->Update(sType, bForce));
  2208.     }
  2209.  
  2210. CdbRecordset        CdbRecordset::Clone(
  2211.     VOID)
  2212.     {
  2213.     DAORecordset *    prs     = (DAORecordset *)GetInterface();
  2214.     DAORecordset *    prsNew    = NULL;
  2215.  
  2216.     if (!prs)
  2217.         return FALSE;
  2218.  
  2219.     DAOMFC_CALL(prs->Clone(&prsNew));
  2220.  
  2221.     return prsNew;
  2222.     }
  2223.  
  2224. VOID                CdbRecordset::Requery(
  2225.     CdbQueryDef *pq)    // = NULL
  2226.     {
  2227.     DAORecordset *    prs     = (DAORecordset *)GetInterface();
  2228.     COleVariant        Var;
  2229.  
  2230.     //Manually load the Query Def as a dispatch
  2231.     if (!pq)
  2232.         {
  2233.         Var.vt            = VT_ERROR;
  2234.         Var.scode        = DISP_E_PARAMNOTFOUND;
  2235.         }
  2236.     else
  2237.         {
  2238.         Var.vt            = VT_DISPATCH;
  2239.         Var.pdispVal    = (LPDISPATCH)pq->GetInterface();
  2240.         }
  2241.  
  2242.     DAOMFC_CALL(prs->Requery(Var));
  2243.     }
  2244.  
  2245. VOID                CdbRecordset::Move(
  2246.     LONG             lRows,
  2247.     CdbBookmark     *pbm)    // = NULL
  2248.     {
  2249.     LPSAFEARRAY        psa = NULL;
  2250.     COleVariant        Var;
  2251.  
  2252.     if(pbm)
  2253.         {
  2254.         SafeArrayCopy((LPSAFEARRAY)(*pbm), &psa);
  2255.         }
  2256.  
  2257.     DAORecordset *    prs     = (DAORecordset *)GetInterface();
  2258.  
  2259.     //Load the safe array into the COleVariant
  2260.     ATV(psa, Var);
  2261.  
  2262.     DAOMFC_CALL(prs->Move(lRows, Var));
  2263.     }
  2264.  
  2265. VOID                CdbRecordset::FillCache(
  2266.     LONG             lRows,    // = -1
  2267.     CdbBookmark *    pbm)    // = NULL
  2268.     {
  2269.     DAORecordset *    prs     = (DAORecordset *)GetInterface();
  2270.     COleVariant        Var;
  2271.  
  2272.     //Load the safe array into the COleVariant
  2273.     ATV((pbm ? pbm->parray:NULL), Var);
  2274.         
  2275.     DAOMFC_CALL(prs->FillCache(OLTV(lRows), Var));
  2276.     }
  2277.  
  2278. CdbQueryDef            CdbRecordset::CopyQueryDef(
  2279.     VOID)
  2280.     {
  2281.     DAORecordset *    prs     = (DAORecordset *)GetInterface();
  2282.     DAOQueryDef *    pqd        = NULL;
  2283.  
  2284.     if (!prs)
  2285.         return (DAOQueryDef *)NULL;
  2286.  
  2287.     DAOMFC_CALL(prs->CopyQueryDef(&pqd));
  2288.  
  2289.     return pqd;
  2290.     }
  2291.  
  2292. COleVariant            CdbRecordset::GetRows(
  2293.     LONG lRows)        // = -1
  2294.     {
  2295.     DAORecordset *    prs     = (DAORecordset *)GetInterface();
  2296.     VARIANT            v;
  2297.  
  2298.     if (!prs)
  2299.         return (LPVARIANT)NULL;
  2300.  
  2301.     VariantInit(&v);
  2302.     DAOMFC_CALL(prs->GetRows(OLTV(lRows), &v));
  2303.  
  2304.     return v;
  2305.     }
  2306.  
  2307. LONG                CdbRecordset::GetRowsEx(
  2308.     LPVOID                pvBuffer,
  2309.     LONG                cbRow,
  2310.     LPDAORSETBINDING     prb,
  2311.     LONG                 cBinding,
  2312.     LPVOID                pvVarBuffer, //= NULL
  2313.     LONG                cbVarBuffer, // = 0
  2314.     LONG                lRows)        // = -1
  2315.     {
  2316.     ICDAORecordset *    prs;
  2317.     DAOFETCHROWS        fetch;
  2318.     HRESULT                hresult;
  2319.     LONG                iBinding;
  2320.     
  2321.     ASSERT(cBinding > 0);
  2322.     ASSERT(prb != 0);
  2323.  
  2324.     //Clear flags
  2325.     fetch.dwFlags = 0;
  2326.  
  2327.     //The GetRowsEx interface isn't set until the first time this function
  2328.     //is called
  2329.     if(!m_GetRowsInt.Exists())
  2330.         SetGetRowsExInt();
  2331.  
  2332.     prs    = (ICDAORecordset *)m_GetRowsInt.GetInterface();
  2333.  
  2334.     if (!prs)
  2335.         return 0L;
  2336.  
  2337.     LPDAOCOLUMNBINDING     pColumnBind = new DAOCOLUMNBINDING [cBinding];
  2338.  
  2339.     for(iBinding=0;iBinding<cBinding;iBinding++)
  2340.         {
  2341.         if(prb[iBinding].dwBindIndexType == dbBindIndexINT)
  2342.             {
  2343.             pColumnBind[iBinding].columnID.dwKind = DAOCOLKIND_IND;
  2344.             pColumnBind[iBinding].columnID.ind = prb[iBinding].i;
  2345.             }
  2346.         else
  2347.             {
  2348. #ifdef _UNICODE
  2349.             pColumnBind[iBinding].columnID.dwKind = DAOCOLKIND_WSTR;
  2350.             pColumnBind[iBinding].columnID.lpwstr = prb[iBinding].pstr;
  2351. #else
  2352.             pColumnBind[iBinding].columnID.dwKind = DAOCOLKIND_STR;
  2353.             pColumnBind[iBinding].columnID.lpstr = prb[iBinding].pstr;
  2354. #endif
  2355.  
  2356.             }
  2357.         pColumnBind[iBinding].cbDataOffset    = prb[iBinding].dwOffset;
  2358.         pColumnBind[iBinding].cbMaxLen        = prb[iBinding].cb;
  2359.         pColumnBind[iBinding].cbInfoOffset    = DAO_NOINDICATOR;
  2360.         
  2361.         //Variants bound differently
  2362.         if(prb[iBinding].dwType != dbBindVARIANT)
  2363.             {
  2364.             pColumnBind[iBinding].dwBinding        = DAOBINDING_DIRECT;
  2365.             }
  2366.         else
  2367.             {
  2368.             pColumnBind[iBinding].dwBinding        = DAOBINDING_VARIANT;
  2369.             }
  2370.         pColumnBind[iBinding].dwDataType    = prb[iBinding].dwType;
  2371.         pColumnBind[iBinding].dwUser        = 0;
  2372.         }
  2373.  
  2374.     fetch.cRowsRequested = lRows;
  2375.     fetch.pData = pvBuffer;
  2376.     fetch.pVarData = pvVarBuffer;
  2377.     fetch.cbVarData = cbVarBuffer;
  2378.  
  2379.     hresult = prs->GetRows(0, cBinding, (LPDAOCOLUMNBINDING)&pColumnBind[0], cbRow, (LPDAOFETCHROWS)&fetch);
  2380.  
  2381.     /* Since the DAO GetRowsEx interface will only deliver ANSI string data inside of
  2382.        variants, we'll convert them here to UNICODE */
  2383.  
  2384. #ifdef UNICODE
  2385.     {
  2386.     LPVARIANT    lpV;
  2387.     LONG        lcb;
  2388.     BSTR        bstrNew;
  2389.  
  2390.     for(LONG iBinding=0;iBinding<cBinding;iBinding++)
  2391.         {
  2392.         if(pColumnBind[iBinding].dwBinding == DAOBINDING_VARIANT)
  2393.             {
  2394.             lpV = (LPVARIANT)(((char *)pvBuffer) + pColumnBind[iBinding].cbDataOffset);
  2395.             for(UINT i = 0; i < fetch.cRowsReturned; i++)
  2396.                 {
  2397.                 //If it's a string, convert it to UNICODE
  2398.                 if(lpV->vt == VT_BSTR)
  2399.                     {
  2400.                     lcb = SysStringByteLen(lpV->bstrVal);
  2401.                     if (!(bstrNew = SysAllocStringLen(NULL, lcb)))
  2402.                         {
  2403.                         hresult = ResultFromScode(E_OUTOFMEMORY);
  2404.                         break;
  2405.                         }
  2406.     
  2407.                     // Convert from ANSI to WIDE
  2408.                     if (lcb && !(lcb = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (LPSTR)lpV->bstrVal,
  2409.                         lcb, (LPWSTR)bstrNew, lcb)))
  2410.                         {
  2411.                         SysFreeString(bstrNew);
  2412.                         hresult = ResultFromScode(E_OUTOFMEMORY);
  2413.                         break;
  2414.                         }
  2415.  
  2416.                     // Make sure it's NULL terminated
  2417.                     ((LPWSTR)(bstrNew))[lcb] = L'\0';
  2418.  
  2419.                     SysFreeString(lpV->bstrVal);
  2420.                     lpV->bstrVal = bstrNew;
  2421.                     }
  2422.                 lpV = (LPVARIANT)(((char *)lpV) + cbRow);
  2423.                 }
  2424.             }
  2425.         }
  2426.     }
  2427. #endif
  2428.  
  2429.     delete [] pColumnBind;
  2430.  
  2431.     //Check return code
  2432.     signed long lErr;
  2433.  
  2434.     switch (GetScode(hresult))
  2435.         {
  2436.         case E_ROWTOOSHORT:
  2437.             lErr = errVtoRowLenTooSmall;
  2438.             break;
  2439.  
  2440.         case E_BADBINDINFO:
  2441.             lErr = errVtoBadBindInfo;
  2442.             break;
  2443.  
  2444.         case E_COLUMNUNAVAILABLE:
  2445.             lErr = errVtoColumnMissing;
  2446.             break;
  2447.             
  2448.         default:            
  2449.             lErr = 0L;
  2450.             }
  2451.  
  2452.     if(lErr)
  2453.         {
  2454.         prs->AddGetRowsErr(lErr);
  2455.         }
  2456.  
  2457.     if(FAILED(hresult)) 
  2458.         {
  2459.         TRACE0("\nGetRowsEX Call Failed.\n\t"); 
  2460.         TRACE2("\nIn file %s on line %d\n", _T("DBDAO.CPP"), __LINE__); \
  2461.         TRACE1("hResult = %X\n", hresult);
  2462.         if (GetScode(hresult) == E_OUTOFMEMORY)
  2463.             {
  2464.             AfxThrowMemoryException();
  2465.             }
  2466.         else
  2467.             {
  2468.             throw CdbException(hresult);
  2469.             }
  2470.     
  2471.         }
  2472.  
  2473.     return fetch.cRowsReturned;
  2474.     }
  2475.  
  2476. COleVariant            CdbRecordset::GetField(
  2477.     COleVariant &Index)
  2478.     {
  2479.     COleVariant vValue;
  2480.  
  2481.     GetFieldV(Index, vValue);
  2482.       
  2483.     return vValue;
  2484.     }
  2485.  
  2486. COleVariant            CdbRecordset::GetField(
  2487.     LPCTSTR pstrIndex)
  2488.     {
  2489.     COleVariant vValue;
  2490.  
  2491.     GetFieldV(STV(pstrIndex), vValue);
  2492.       
  2493.     return vValue;
  2494.     }
  2495.  
  2496. COleVariant            CdbRecordset::GetField(
  2497.     LONG lIndex)
  2498.     {
  2499.     COleVariant vValue;
  2500.          
  2501.     GetFieldV(LTV(lIndex), vValue);
  2502.       
  2503.     return vValue;
  2504.     }
  2505.  
  2506. VOID            CdbRecordset::SetField(
  2507.     LPCTSTR pstrIndex,
  2508.     LPVARIANT pv)
  2509.     {
  2510.     SetFieldV(STV(pstrIndex), pv);
  2511.     }
  2512.  
  2513. VOID            CdbRecordset::SetField(
  2514.     COleVariant &Index,
  2515.     LPVARIANT pv)
  2516.     {
  2517.     SetFieldV(Index, pv);
  2518.     }
  2519.  
  2520. VOID            CdbRecordset::SetField(
  2521.     LONG lIndex,
  2522.     LPVARIANT pv)
  2523.     {
  2524.     SetFieldV(LTV(lIndex), pv);
  2525.     }
  2526.  
  2527. VOID            CdbRecordset::Cancel(
  2528.     VOID)
  2529.     {
  2530.     DAORecordset *    prs     = (DAORecordset *)GetInterface();
  2531.  
  2532.     if (!prs)
  2533.         return;
  2534.  
  2535.     DAOMFC_CALL(prs->Cancel());
  2536.     }
  2537.  
  2538. BOOL            CdbRecordset::NextRecordset(
  2539.     VOID)
  2540.     {
  2541.     BPROPGET(DAORecordset, NextRecordset);
  2542.     }
  2543.  
  2544. /*****************************************************************************
  2545. * CdbGetRowsEx
  2546. */
  2547. // Administration
  2548. CONSTRUCTOR            CdbGetRowsEx::CdbGetRowsEx(
  2549.     VOID)
  2550.     {
  2551.     }
  2552.  
  2553. CONSTRUCTOR            CdbGetRowsEx::CdbGetRowsEx(
  2554.     ICDAORecordset *    pGetRows,
  2555.     BOOL         bAddRef)    // = FALSE
  2556.     {
  2557.     CdbOleObject::SetInterface((LPUNKNOWN)pGetRows, bAddRef);
  2558.     }
  2559.  
  2560. CONSTRUCTOR            CdbGetRowsEx::CdbGetRowsEx(
  2561.     const CdbGetRowsEx &o)
  2562.     {
  2563.     SetInterface(o.GetInterface(TRUE));
  2564.     }
  2565.  
  2566. CdbGetRowsEx &            CdbGetRowsEx::operator =(
  2567.     const CdbGetRowsEx &o)
  2568.     {
  2569.     SetInterface(o.GetInterface(TRUE));
  2570.     return *this;
  2571.     }
  2572.  
  2573.  
  2574. VOID            CdbGetRowsEx::OnInterfaceChange(
  2575.     VOID)
  2576.     {
  2577.     ICDAORecordset * pGetRows     = (ICDAORecordset *)GetInterface();
  2578.  
  2579.     }
  2580.  
  2581.  
  2582. /*****************************************************************************
  2583. * CdbField
  2584. */
  2585. // Administration
  2586. CONSTRUCTOR            CdbField::CdbField(
  2587.     VOID)
  2588.     {
  2589.     }
  2590.  
  2591. CONSTRUCTOR            CdbField::CdbField(
  2592.     DAOField *    pfld,
  2593.     BOOL         bAddRef)    // = FALSE
  2594.     {
  2595.     CdbOleObject::SetInterface((LPUNKNOWN)pfld, bAddRef);
  2596.     }
  2597.  
  2598. CONSTRUCTOR            CdbField::CdbField(
  2599.     const CdbField &o)
  2600.     {
  2601.     SetInterface(o.GetInterface(TRUE));
  2602.     }
  2603.  
  2604. CdbField &            CdbField::operator =(
  2605.     const CdbField &o)
  2606.     {
  2607.     SetInterface(o.GetInterface(TRUE));
  2608.     return *this;
  2609.     }
  2610.  
  2611. VOID                CdbField::OnInterfaceChange(
  2612.     VOID)
  2613.     {
  2614.     DAOField *        pfld    = (DAOField *)GetInterface();
  2615.     DAOProperties *    pprps    = NULL;
  2616.  
  2617.     if (pfld)
  2618.         {
  2619.         pfld->get_Properties(&pprps);
  2620.         }
  2621.  
  2622.     Properties.SetInterface(pprps);
  2623.     }
  2624.  
  2625. // Properties
  2626. LONG                CdbField::GetCollatingOrder(
  2627.     VOID)
  2628.     {
  2629.     LPROPGET(DAOField, get_CollatingOrder);
  2630.     }
  2631.  
  2632. SHORT                CdbField::GetType(
  2633.     VOID)
  2634.     {
  2635.     WPROPGET(DAOField, get_Type);
  2636.     }
  2637.  
  2638. VOID                CdbField::SetType(
  2639.     SHORT s)
  2640.     {
  2641.     WPROPSET(DAOField, put_Type, s);
  2642.     }
  2643.  
  2644. CString                CdbField::GetName(
  2645.     VOID)
  2646.     {
  2647.     SPROPGET(DAOField, get_Name);
  2648.     }
  2649.  
  2650. VOID                CdbField::SetName(
  2651.     LPCTSTR pstr)
  2652.     {
  2653.     SPROPSET(DAOField, put_Name, pstr);
  2654.     }
  2655.  
  2656. LONG                CdbField::GetSize(
  2657.     VOID)
  2658.     {
  2659.     LPROPGET(DAOField, get_Size);
  2660.     }
  2661.  
  2662. VOID                CdbField::SetSize(
  2663.     LONG l)
  2664.     {
  2665.     LPROPSET(DAOField, put_Size, l);
  2666.     }
  2667.  
  2668. CString                CdbField::GetSourceField(
  2669.     VOID)
  2670.     {
  2671.     SPROPGET(DAOField, get_SourceField);
  2672.     }
  2673.  
  2674. CString                CdbField::GetSourceTable(
  2675.     VOID)
  2676.     {
  2677.     SPROPGET(DAOField, get_SourceTable);
  2678.     }
  2679.  
  2680. COleVariant            CdbField::GetValue(
  2681.     VOID)
  2682.     {
  2683.     VPROPGET(DAOField, get_Value);
  2684.     }
  2685.  
  2686.  
  2687. VOID                CdbField::SetValue(
  2688.     LPVARIANT pv)
  2689.     {
  2690.     VPROPSET(DAOField, put_Value, pv);
  2691.     }
  2692.  
  2693. LONG                CdbField::GetAttributes(
  2694.     VOID)
  2695.     {
  2696.     LPROPGET(DAOField, get_Attributes);
  2697.     }
  2698.  
  2699. VOID                CdbField::SetAttributes(
  2700.     LONG l)
  2701.     {
  2702.     LPROPSET(DAOField, put_Attributes, l);
  2703.     }
  2704.  
  2705. SHORT                CdbField::GetOrdinalPosition(
  2706.     VOID)
  2707.     {
  2708.     WPROPGET(DAOField, get_OrdinalPosition);
  2709.     }
  2710.  
  2711. VOID                CdbField::SetOrdinalPosition(
  2712.     SHORT s)
  2713.     {
  2714.     WPROPSET(DAOField, put_OrdinalPosition, s);
  2715.     }
  2716.  
  2717. CString                CdbField::GetValidationText(
  2718.     VOID)
  2719.     {
  2720.     SPROPGET(DAOField, get_ValidationText);
  2721.     }
  2722.  
  2723. VOID                CdbField::SetValidationText(
  2724.     LPCTSTR pstr)
  2725.     {
  2726.     SPROPSET(DAOField, put_ValidationText, pstr);
  2727.     }
  2728.  
  2729. BOOL                CdbField::GetValidateOnSet(
  2730.     VOID)
  2731.     {
  2732.     BPROPGET(DAOField, get_ValidateOnSet);
  2733.     }
  2734.  
  2735. VOID                CdbField::SetValidateOnSet(
  2736.     BOOL b)
  2737.     {
  2738.     BPROPSET(DAOField, put_ValidateOnSet, b);
  2739.     }
  2740.  
  2741. CString                CdbField::GetValidationRule(
  2742.     VOID)
  2743.     {
  2744.     SPROPGET(DAOField, get_ValidationRule);
  2745.     }
  2746.  
  2747. VOID                CdbField::SetValidationRule(
  2748.     LPCTSTR pstr)
  2749.     {
  2750.     SPROPSET(DAOField, put_ValidationRule, pstr);
  2751.     }
  2752.  
  2753. VOID                CdbField::SetDefaultValue(
  2754.     LPCTSTR pstr)
  2755.     {
  2756.     VPROPSET(DAOField, put_DefaultValue, STV(pstr));
  2757.     }
  2758.  
  2759. CString                CdbField::GetDefaultValue(
  2760.     VOID)
  2761.     {
  2762.     DAOField *        pfld    = (DAOField *)GetInterface();
  2763.     VARIANT            vDAO;
  2764.  
  2765.     if (!pfld)
  2766.         return (LPCSTR)NULL;
  2767.  
  2768.     VariantInit(&vDAO);
  2769.     DAOMFC_CALL(pfld->get_DefaultValue(&vDAO));
  2770.  
  2771.     //User is expecting a CString so force this variant into one.
  2772.     if(GetScode((VariantChangeType(&vDAO, &vDAO, 0, VT_BSTR))) != S_OK)
  2773.         {
  2774.         return (LPCTSTR)NULL;
  2775.         }
  2776.  
  2777.     return((LPCTSTR)vDAO.bstrVal);
  2778.     }
  2779.  
  2780. VOID                CdbField::SetDefaultValue(
  2781.     LPVARIANT pv)
  2782.     {
  2783.     VPROPSET(DAOField, put_DefaultValue, pv);
  2784.     }
  2785.  
  2786. BOOL                CdbField::GetRequired(
  2787.     VOID)
  2788.     {
  2789.     BPROPGET(DAOField, get_Required);
  2790.     }
  2791.  
  2792. VOID                CdbField::SetRequired(
  2793.     BOOL b)
  2794.     {
  2795.     BPROPSET(DAOField, put_Required, b);
  2796.     }
  2797.  
  2798. BOOL                CdbField::GetAllowZeroLength(
  2799.     VOID)
  2800.     {
  2801.     BPROPGET(DAOField, get_AllowZeroLength);
  2802.     }
  2803.  
  2804. VOID                CdbField::SetAllowZeroLength(
  2805.     BOOL b)
  2806.     {
  2807.     BPROPSET(DAOField, put_AllowZeroLength, b);
  2808.     }
  2809.  
  2810. BOOL                CdbField::GetDataUpdatable(
  2811.     VOID)
  2812.     {
  2813.     BPROPGET(DAOField, get_DataUpdatable);
  2814.     }
  2815.  
  2816. CString                CdbField::GetForeignName(
  2817.     VOID)
  2818.     {
  2819.     SPROPGET(DAOField, get_ForeignName);
  2820.     }
  2821.  
  2822. VOID                CdbField::SetForeignName(
  2823.     LPCTSTR pstr)
  2824.     {
  2825.     SPROPSET(DAOField, put_ForeignName, pstr);
  2826.     }
  2827.  
  2828. COleVariant            CdbField::GetOriginalValue(
  2829.     VOID)
  2830.     {
  2831.     VPROPGET(DAOField, get_OriginalValue);
  2832.     }
  2833.  
  2834. COleVariant            CdbField::GetVisibleValue(
  2835.     VOID)
  2836.     {
  2837.     VPROPGET(DAOField, get_VisibleValue);
  2838.     }
  2839.  
  2840. // Methods
  2841. VOID                CdbField::AppendChunk(
  2842.     LPVARIANT pv)
  2843.     {
  2844.     DAOField *        pfld    = (DAOField *)GetInterface();
  2845.  
  2846.     DAOMFC_CALL(pfld->AppendChunk(*pv));
  2847.     }
  2848.  
  2849. COleVariant            CdbField::GetChunk(
  2850.     LONG lOffset,
  2851.     LONG lBytes)
  2852.     {
  2853.     DAOField *        pfld    = (DAOField *)GetInterface();
  2854.     COleVariant        v;
  2855.  
  2856.     if (!pfld)
  2857.         return (LPVARIANT)NULL;
  2858.  
  2859.     VariantInit(&v);
  2860.     DAOMFC_CALL(pfld->GetChunk(lOffset, lBytes, &v));
  2861.  
  2862.     return &v;
  2863.     }
  2864.  
  2865. LONG                CdbField::FieldSize(
  2866.     VOID)
  2867.     {
  2868.     DAOField *        pfld    = (DAOField *)GetInterface();
  2869.     LONG            l        = 0;
  2870.  
  2871.     if (!pfld)
  2872.         return 0;
  2873.  
  2874.     DAOMFC_CALL(pfld->get_FieldSize(&l));
  2875.  
  2876.     return l;
  2877.     }
  2878.  
  2879. CdbProperty            CdbField::CreateProperty(
  2880.     LPCTSTR        pstrName,    // = NULL
  2881.     LONG        lType,        // = -1
  2882.     LPVARIANT    pvValue,    // = NULL
  2883.     BOOL        bDDL)        // = FALSE
  2884.     {
  2885.     DAOField *    pfld        = (DAOField *)GetInterface();
  2886.     DAOProperty *    pprp    = NULL;
  2887.  
  2888.     if (!pfld)
  2889.         return (DAOProperty *)NULL;
  2890.  
  2891.     DAOMFC_CALL(pfld->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
  2892.  
  2893.     return pprp;
  2894.     }
  2895.  
  2896. /*****************************************************************************
  2897. * CdbQueryDef
  2898. */
  2899. // Administration
  2900. CONSTRUCTOR            CdbQueryDef::CdbQueryDef(
  2901.     VOID)
  2902.     {
  2903.     }
  2904.  
  2905. CONSTRUCTOR            CdbQueryDef::CdbQueryDef(
  2906.     DAOQueryDef *    pqd,
  2907.     BOOL             bAddRef)    // FALSE
  2908.     {
  2909.     CdbOleObject::SetInterface((LPUNKNOWN)pqd, bAddRef);
  2910.     }
  2911.  
  2912. CONSTRUCTOR            CdbQueryDef::CdbQueryDef(
  2913.     const CdbQueryDef &o)
  2914.     {
  2915.     SetInterface(o.GetInterface(TRUE));
  2916.     }
  2917.  
  2918. CdbQueryDef &        CdbQueryDef::operator =(
  2919.     const CdbQueryDef &o)
  2920.     {
  2921.     SetInterface(o.GetInterface(TRUE));
  2922.     return *this;
  2923.     }
  2924.  
  2925. VOID                CdbQueryDef::OnInterfaceChange(
  2926.     VOID)
  2927.     {
  2928.     DAOQueryDef *    pqd        = (DAOQueryDef *)GetInterface();
  2929.     DAOProperties *    pprps    = NULL;
  2930.     DAOFields *        pflds    = NULL;
  2931.     DAOParameters *    pprms    = NULL;
  2932.  
  2933.     if (pqd)
  2934.         {
  2935.         pqd->get_Properties(&pprps);
  2936.         pqd->get_Fields(&pflds);
  2937.         pqd->get_Parameters(&pprms);
  2938.         }
  2939.  
  2940.     Properties.SetInterface(pprps);
  2941.     Fields.SetInterface(pflds);
  2942.     Parameters.SetInterface(pprms);
  2943.     }
  2944.  
  2945. // Properties
  2946. COleDateTime            CdbQueryDef::GetDateCreated(
  2947.     VOID)
  2948.     {
  2949.     DPROPGET(DAOQueryDef, get_DateCreated);
  2950.     }
  2951.  
  2952. COleDateTime            CdbQueryDef::GetLastUpdated(
  2953.     VOID)
  2954.     {
  2955.     DPROPGET(DAOQueryDef, get_LastUpdated);
  2956.     }
  2957.  
  2958. CString                CdbQueryDef::GetName(
  2959.     VOID)
  2960.     {
  2961.     SPROPGET(DAOQueryDef, get_Name);
  2962.     }
  2963.  
  2964. VOID                CdbQueryDef::SetName(
  2965.     LPCTSTR pstr)
  2966.     {
  2967.     SPROPSET(DAOQueryDef, put_Name, pstr);
  2968.     }
  2969.  
  2970. SHORT                CdbQueryDef::GetODBCTimeout(
  2971.     VOID)
  2972.     {
  2973.     WPROPGET(DAOQueryDef, get_ODBCTimeout);
  2974.     }
  2975.  
  2976. VOID                CdbQueryDef::SetODBCTimeout(
  2977.     SHORT s)
  2978.     {
  2979.     WPROPSET(DAOQueryDef, put_ODBCTimeout, s);
  2980.     }
  2981.  
  2982. SHORT                CdbQueryDef::GetType(
  2983.     VOID)
  2984.     {
  2985.     WPROPGET(DAOQueryDef, get_Type);
  2986.     }
  2987.  
  2988. CString                CdbQueryDef::GetSQL(
  2989.     VOID)
  2990.     {
  2991.     SPROPGET(DAOQueryDef, get_SQL);
  2992.     }
  2993.  
  2994. VOID                CdbQueryDef::SetSQL(
  2995.     LPCTSTR pstr)
  2996.     {
  2997.     SPROPSET(DAOQueryDef, put_SQL, pstr);
  2998.     }
  2999.  
  3000. BOOL                CdbQueryDef::GetUpdatable(
  3001.     VOID)
  3002.     {
  3003.     BPROPGET(DAOQueryDef, get_Updatable);
  3004.     }
  3005.  
  3006. CString                CdbQueryDef::GetConnect(
  3007.     VOID)
  3008.     {
  3009.     SPROPGET(DAOQueryDef, get_Connect);
  3010.     }
  3011.  
  3012. VOID                CdbQueryDef::SetConnect(
  3013.     LPCTSTR pstr)
  3014.     {
  3015.     SPROPSET(DAOQueryDef, put_Connect, pstr);
  3016.     }
  3017.  
  3018. BOOL                CdbQueryDef::GetReturnsRecords(
  3019.     VOID)
  3020.     {
  3021.     BPROPGET(DAOQueryDef, get_ReturnsRecords);
  3022.     }
  3023.  
  3024. VOID                CdbQueryDef::SetReturnsRecords(
  3025.     BOOL b)
  3026.     {
  3027.     BPROPSET(DAOQueryDef, put_ReturnsRecords, b);
  3028.     }
  3029.  
  3030. LONG                CdbQueryDef::GetRecordsAffected(
  3031.     VOID)
  3032.     {
  3033.     LPROPGET(DAOQueryDef, get_RecordsAffected);
  3034.     }
  3035.  
  3036. LONG                CdbQueryDef::GetMaxRecords(
  3037.     VOID)
  3038.     {
  3039.     LPROPGET(DAOQueryDef, get_MaxRecords);
  3040.     }
  3041.  
  3042. VOID                CdbQueryDef::SetMaxRecords(
  3043.     LONG l)
  3044.     {
  3045.     LPROPSET(DAOQueryDef, put_MaxRecords, l);
  3046.     }
  3047.  
  3048. BOOL                CdbQueryDef::GetStillExecuting(
  3049.     VOID)
  3050.     {
  3051.     BPROPGET(DAOQueryDef, get_StillExecuting);
  3052.     }
  3053.  
  3054. LONG                CdbQueryDef::GetCacheSize(
  3055.     VOID)
  3056.     {
  3057.     LPROPGET(DAOQueryDef, get_CacheSize);
  3058.     }
  3059.  
  3060. VOID                CdbQueryDef::SetCacheSize(
  3061.     LONG l)
  3062.     {
  3063.     LPROPSET(DAOQueryDef, put_CacheSize, l);
  3064.     }
  3065.  
  3066. COleVariant            CdbQueryDef::GetPrepare(
  3067.     VOID)
  3068.     {
  3069.     VPROPGET(DAOQueryDef, get_Prepare);
  3070.     }
  3071.  
  3072. VOID                CdbQueryDef::SetPrepare(
  3073.     LPVARIANT pv)
  3074.     {
  3075.     DAOQueryDef *    pqd    = (DAOQueryDef *)GetInterface();
  3076.  
  3077.     DAOMFC_CALL(pqd->put_Prepare(*pv));
  3078.     }
  3079.  
  3080. // Methods
  3081. CdbRecordset        CdbQueryDef::OpenRecordset(
  3082.     LONG lType,        // = -1
  3083.     LONG lOption,    // = -1
  3084.     LONG lLockEdit) // = -1
  3085.     {
  3086.     DAOQueryDef *    pqd = (DAOQueryDef *)GetInterface();
  3087.     DAORecordset *    prs    = NULL;
  3088.  
  3089.     if (!pqd)
  3090.         return (DAORecordset *)NULL;
  3091.  
  3092.     DAOMFC_CALL(pqd->OpenRecordset(OLTV(lType), OLTV(lOption), OLTV(lLockEdit), &prs));
  3093.  
  3094.     return prs;
  3095.     }
  3096.  
  3097. VOID                CdbQueryDef::Execute(
  3098.     LONG lOption)    // = -1
  3099.     {
  3100.     DAOQueryDef *    pqd = (DAOQueryDef *)GetInterface();
  3101.  
  3102.     DAOMFC_CALL(pqd->Execute(OLTV(lOption)));
  3103.     }
  3104.  
  3105. CdbProperty            CdbQueryDef::CreateProperty(
  3106.     LPCTSTR        pstrName,    // = NULL
  3107.     LONG        lType,        // = -1
  3108.     LPVARIANT    pvValue,    // = NULL
  3109.     BOOL        bDDL)        // = FALSE
  3110.     {
  3111.     DAOQueryDef *    pqd        = (DAOQueryDef *)GetInterface();
  3112.     DAOProperty *    pprp    = NULL;
  3113.  
  3114.     if (!pqd)
  3115.         return (DAOProperty *)NULL;
  3116.  
  3117.     DAOMFC_CALL(pqd->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
  3118.  
  3119.     return pprp;
  3120.     }
  3121.  
  3122. VOID                CdbQueryDef::Close(
  3123.     VOID)
  3124.     {
  3125.     DAOQueryDef *    pqd = (DAOQueryDef *)GetInterface();
  3126.  
  3127.     if (!pqd)
  3128.         return;
  3129.  
  3130.     DAOMFC_CALL(pqd->Close());
  3131.     }
  3132.  
  3133. VOID                CdbQueryDef::Cancel(
  3134.     VOID)
  3135.     {
  3136.     DAOQueryDef *    pqd = (DAOQueryDef *)GetInterface();
  3137.  
  3138.     if (!pqd)
  3139.         return;
  3140.  
  3141.     DAOMFC_CALL(pqd->Cancel());
  3142.     }
  3143.  
  3144. /*****************************************************************************
  3145. * CdbTableDef
  3146. */
  3147. // Administration
  3148. CONSTRUCTOR            CdbTableDef::CdbTableDef(
  3149.     VOID)
  3150.     {
  3151.     }
  3152.  
  3153. CONSTRUCTOR            CdbTableDef::CdbTableDef(
  3154.     DAOTableDef *    ptd,
  3155.     BOOL             bAddRef)    // = FALSE
  3156.     {
  3157.     CdbOleObject::SetInterface((LPUNKNOWN)ptd, bAddRef);
  3158.     }
  3159.  
  3160. CONSTRUCTOR            CdbTableDef::CdbTableDef(
  3161.     const CdbTableDef &o)
  3162.     {
  3163.     SetInterface(o.GetInterface(TRUE));
  3164.     }
  3165.  
  3166. CdbTableDef &        CdbTableDef::operator =(
  3167.     const CdbTableDef &o)
  3168.     {
  3169.     SetInterface(o.GetInterface(TRUE));
  3170.     return *this;
  3171.     }
  3172.  
  3173. VOID                CdbTableDef::OnInterfaceChange(
  3174.     VOID)
  3175.     {
  3176.     DAOTableDef *    ptd        = (DAOTableDef *)GetInterface();
  3177.     DAOProperties *    pprps    = NULL;
  3178.     DAOFields *        pflds    = NULL;
  3179.     DAOIndexes *    pidxs    = NULL;
  3180.  
  3181.     if (ptd)
  3182.         {
  3183.         ptd->get_Properties(&pprps);
  3184.         ptd->get_Fields(&pflds);
  3185.         ptd->get_Indexes(&pidxs);
  3186.         }
  3187.  
  3188.     Properties.SetInterface(pprps);
  3189.     Fields.SetInterface(pflds);
  3190.     Indexes.SetInterface(pidxs);
  3191.     }
  3192.  
  3193. // Properties
  3194. LONG                CdbTableDef::GetAttributes(
  3195.     VOID)
  3196.     {
  3197.     LPROPGET(DAOTableDef, get_Attributes);
  3198.     }
  3199.  
  3200. VOID                CdbTableDef::SetAttributes(
  3201.     LONG l)
  3202.     {
  3203.     LPROPSET(DAOTableDef, put_Attributes, l);
  3204.     }
  3205.  
  3206. CString                CdbTableDef::GetConnect(
  3207.     VOID)
  3208.     {
  3209.     SPROPGET(DAOTableDef, get_Connect);
  3210.     }
  3211.  
  3212. VOID                CdbTableDef::SetConnect(
  3213.     LPCTSTR pstr)
  3214.     {
  3215.     SPROPSET(DAOTableDef, put_Connect, pstr);
  3216.     }
  3217.  
  3218. COleDateTime            CdbTableDef::GetDateCreated(
  3219.     VOID)
  3220.     {
  3221.     DPROPGET(DAOTableDef, get_DateCreated);
  3222.     }
  3223.  
  3224. COleDateTime            CdbTableDef::GetLastUpdated(
  3225.     VOID)
  3226.     {
  3227.     DPROPGET(DAOTableDef, get_LastUpdated);
  3228.     }
  3229.  
  3230. CString                CdbTableDef::GetName(
  3231.     VOID)
  3232.     {
  3233.     SPROPGET(DAOTableDef, get_Name);
  3234.     }
  3235.  
  3236. VOID                CdbTableDef::SetName(
  3237.     LPCTSTR pstr)
  3238.     {
  3239.     SPROPSET(DAOTableDef, put_Name, pstr);
  3240.     }
  3241.  
  3242. CString                CdbTableDef::GetSourceTableName(
  3243.     VOID)
  3244.     {
  3245.     SPROPGET(DAOTableDef, get_SourceTableName);
  3246.     }
  3247.  
  3248. VOID                CdbTableDef::SetSourceTableName(
  3249.     LPCTSTR pstr)
  3250.     {
  3251.     SPROPSET(DAOTableDef, put_SourceTableName, pstr);
  3252.     }
  3253.  
  3254. BOOL                CdbTableDef::GetUpdatable(
  3255.     VOID)
  3256.     {
  3257.     BPROPGET(DAOTableDef, get_Updatable);
  3258.     }
  3259.  
  3260. CString                CdbTableDef::GetValidationText(
  3261.     VOID)
  3262.     {
  3263.     SPROPGET(DAOTableDef, get_ValidationText);
  3264.     }
  3265.  
  3266. VOID                CdbTableDef::SetValidationText(
  3267.     LPCTSTR pstr)
  3268.     {
  3269.     SPROPSET(DAOTableDef, put_ValidationText, pstr);
  3270.     }
  3271.  
  3272. CString                CdbTableDef::GetValidationRule(
  3273.     VOID)
  3274.     {
  3275.     SPROPGET(DAOTableDef, get_ValidationRule);
  3276.     }
  3277.  
  3278. VOID                CdbTableDef::SetValidationRule(
  3279.     LPCTSTR pstr)
  3280.     {
  3281.     SPROPSET(DAOTableDef, put_ValidationRule, pstr);
  3282.     }
  3283.  
  3284. LONG                CdbTableDef::GetRecordCount(
  3285.     VOID)
  3286.     {
  3287.     LPROPGET(DAOTableDef, get_RecordCount);
  3288.     }
  3289.  
  3290. CString                CdbTableDef::GetConflictTable(
  3291.     VOID)
  3292.     {
  3293.     SPROPGET(DAOTableDef, get_ConflictTable);
  3294.     }
  3295.  
  3296. COleVariant            CdbTableDef::GetReplicaFilter(
  3297.     VOID)
  3298.     {
  3299.     VPROPGET(DAOTableDef, get_ReplicaFilter);
  3300.     }
  3301.  
  3302. VOID                CdbTableDef::SetReplicaFilter(
  3303.     LPVARIANT pv)
  3304.     {
  3305.     VPROPSET(DAOTableDef, put_ReplicaFilter, pv);
  3306.     }
  3307.  
  3308.  
  3309. // Methods
  3310. CdbRecordset        CdbTableDef::OpenRecordset(
  3311.     LONG lType,        // = -1
  3312.     LONG lOption)    // = -1
  3313.     {
  3314.     DAOTableDef *    ptd        = (DAOTableDef *)GetInterface();
  3315.     DAORecordset *    prs        = NULL;
  3316.  
  3317.     if (!ptd)
  3318.         return (DAORecordset *)NULL;
  3319.  
  3320.     DAOMFC_CALL(ptd->OpenRecordset(OLTV(lType), OLTV(lOption), &prs));
  3321.  
  3322.     return prs;
  3323.     }
  3324.  
  3325. VOID                CdbTableDef::RefreshLink(
  3326.     VOID)
  3327.     {
  3328.     DAOTableDef *    ptd        = (DAOTableDef *)GetInterface();
  3329.  
  3330.     DAOMFC_CALL(ptd->RefreshLink());
  3331.     }
  3332.  
  3333. CdbField            CdbTableDef::CreateField(
  3334.     LPCTSTR    pstrName,    // = NULL
  3335.     LONG    lType,        // = -1
  3336.     LONG    lSize)        // = -1
  3337.     {
  3338.     DAOTableDef *    ptd        = (DAOTableDef *)GetInterface();
  3339.     DAOField *        pfld    = NULL;
  3340.  
  3341.     if (!ptd)
  3342.         return (DAOField *)NULL;
  3343.  
  3344.     DAOMFC_CALL(ptd->CreateField(STV(pstrName), OLTV(lType), OLTV(lSize), &pfld));
  3345.  
  3346.     return pfld;
  3347.     }
  3348.  
  3349. CdbIndex            CdbTableDef::CreateIndex(
  3350.     LPCTSTR pstrName)    // = NULL
  3351.     {
  3352.     DAOTableDef *    ptd        = (DAOTableDef *)GetInterface();
  3353.     DAOIndex *        pidx    = NULL;
  3354.  
  3355.     if (!ptd)
  3356.         return (DAOIndex *)NULL;
  3357.  
  3358.     DAOMFC_CALL(ptd->CreateIndex(STV(pstrName), &pidx));
  3359.  
  3360.     return pidx;
  3361.     }
  3362.  
  3363. CdbProperty            CdbTableDef::CreateProperty(
  3364.     LPCTSTR        pstrName,    // = NULL
  3365.     LONG        lType,        // = -1
  3366.     LPVARIANT    pvValue,    // = NULL
  3367.     BOOL        bDDL)        // = FALSE
  3368.     {
  3369.     DAOTableDef *    ptd        = (DAOTableDef *)GetInterface();
  3370.     DAOProperty *    pprp    = NULL;
  3371.  
  3372.     if (!ptd)
  3373.         return (DAOProperty *)NULL;
  3374.  
  3375.     DAOMFC_CALL(ptd->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
  3376.  
  3377.     return pprp;
  3378.     }
  3379.  
  3380. /*****************************************************************************
  3381. * CdbIndex
  3382. */
  3383. // Administration
  3384. CONSTRUCTOR            CdbIndex::CdbIndex(
  3385.     VOID)
  3386.     {
  3387.     }
  3388.  
  3389. CONSTRUCTOR            CdbIndex::CdbIndex(
  3390.     DAOIndex *    pidx,
  3391.     BOOL         bAddRef)    // = FALSE
  3392.     {
  3393.     CdbOleObject::SetInterface((LPUNKNOWN)pidx, bAddRef);
  3394.     }
  3395.  
  3396. CONSTRUCTOR            CdbIndex::CdbIndex(
  3397.     const CdbIndex &o)
  3398.     {
  3399.     SetInterface(o.GetInterface(TRUE));
  3400.     }
  3401.  
  3402. CdbIndex &            CdbIndex::operator =(
  3403.     const CdbIndex &o)
  3404.     {
  3405.     SetInterface(o.GetInterface(TRUE));
  3406.     return *this;
  3407.     }
  3408.  
  3409. VOID                CdbIndex::OnInterfaceChange(
  3410.     VOID)
  3411.     {
  3412.     DAOIndex *        pidx    = (DAOIndex *)GetInterface();
  3413.     DAOProperties *    pprps    = NULL;
  3414.     DAOFields *        pflds    = NULL;
  3415.  
  3416.     if (pidx)
  3417.         {
  3418.         VARIANT    v;
  3419.  
  3420.         VariantInit(&v);
  3421.  
  3422.         pidx->get_Properties(&pprps);
  3423.         pidx->get_Fields(&v);
  3424.  
  3425.         v.pdispVal->QueryInterface(dbIID_IDAOIndexFields, (LPVOID *)&pflds);
  3426.         v.pdispVal->Release();
  3427.         }
  3428.  
  3429.     Properties.SetInterface(pprps);
  3430.     Fields.SetInterface(pflds);
  3431.     }
  3432.  
  3433. // Properties
  3434. CString                CdbIndex::GetName(
  3435.     VOID)
  3436.     {
  3437.     SPROPGET(DAOIndex, get_Name);
  3438.     }
  3439.  
  3440. VOID                CdbIndex::SetName(
  3441.     LPCTSTR pstr)
  3442.     {
  3443.     SPROPSET(DAOIndex, put_Name, pstr);
  3444.     }
  3445.  
  3446. BOOL                CdbIndex::GetForeign(
  3447.     VOID)
  3448.     {
  3449.     BPROPGET(DAOIndex, get_Foreign);
  3450.     }
  3451.  
  3452. BOOL                CdbIndex::GetUnique(
  3453.     VOID)
  3454.     {
  3455.     BPROPGET(DAOIndex, get_Unique);
  3456.     }
  3457.  
  3458. VOID                CdbIndex::SetUnique(
  3459.     BOOL b)
  3460.     {
  3461.     BPROPSET(DAOIndex, put_Unique, b);
  3462.     }
  3463.  
  3464. BOOL                CdbIndex::GetClustered(
  3465.     VOID)
  3466.     {
  3467.     BPROPGET(DAOIndex, get_Clustered);
  3468.     }
  3469.  
  3470. VOID                CdbIndex::SetClustered(
  3471.     BOOL b)
  3472.     {
  3473.     BPROPSET(DAOIndex, put_Clustered, b);
  3474.     }
  3475.  
  3476. BOOL                CdbIndex::GetRequired(
  3477.     VOID)
  3478.     {
  3479.     BPROPGET(DAOIndex, get_Required);
  3480.     }
  3481.  
  3482. VOID                CdbIndex::SetRequired(
  3483.     BOOL b)
  3484.     {
  3485.     BPROPSET(DAOIndex, put_Required, b);
  3486.     }
  3487.  
  3488. BOOL                CdbIndex::GetIgnoreNulls(
  3489.     VOID)
  3490.     {
  3491.     BPROPGET(DAOIndex, get_IgnoreNulls);
  3492.     }
  3493.  
  3494. VOID                CdbIndex::SetIgnoreNulls(
  3495.     BOOL b)
  3496.     {
  3497.     BPROPSET(DAOIndex, put_IgnoreNulls, b);
  3498.     }
  3499.  
  3500. BOOL                CdbIndex::GetPrimary(
  3501.     VOID)
  3502.     {
  3503.     BPROPGET(DAOIndex, get_Primary);
  3504.     }
  3505.  
  3506. VOID                CdbIndex::SetPrimary(
  3507.     BOOL b)
  3508.     {
  3509.     BPROPSET(DAOIndex, put_Primary, b);
  3510.     }
  3511.  
  3512. LONG                CdbIndex::GetDistinctCount(
  3513.     VOID)
  3514.     {
  3515.     LPROPGET(DAOIndex, get_DistinctCount);
  3516.     }
  3517.  
  3518.  
  3519. // Methods
  3520. CdbField            CdbIndex::CreateField(
  3521.     LPCTSTR    pstrName,    // = NULL
  3522.     LONG    lType,        // = -1
  3523.     LONG    lSize)        // = -1
  3524.     {
  3525.     DAOIndex *        pidx    = (DAOIndex *)GetInterface();
  3526.     DAOField *        pfld    = NULL;
  3527.  
  3528.     if (!pidx)
  3529.         return (DAOField *)NULL;
  3530.  
  3531.     DAOMFC_CALL(pidx->CreateField(STV(pstrName), OLTV(lType), OLTV(lSize), &pfld));
  3532.  
  3533.     return pfld;
  3534.     }
  3535.  
  3536. CdbProperty            CdbIndex::CreateProperty(
  3537.     LPCTSTR        pstrName,    // = NULL
  3538.     LONG        lType,        // = -1
  3539.     LPVARIANT    pvValue,    // = NULL
  3540.     BOOL        bDDL)        // = FALSE
  3541.     {
  3542.     DAOIndex *        pidx    = (DAOIndex *)GetInterface();
  3543.     DAOProperty *    pprp    = NULL;
  3544.  
  3545.     if (!pidx)
  3546.         return (DAOProperty *)NULL;
  3547.  
  3548.     DAOMFC_CALL(pidx->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
  3549.  
  3550.     return pprp;
  3551.     }
  3552.  
  3553.  
  3554. /*****************************************************************************
  3555. * CdbProperty
  3556. */
  3557. // Administration
  3558. CONSTRUCTOR            CdbProperty::CdbProperty(
  3559.     VOID)
  3560.     {
  3561.     }
  3562.  
  3563. CONSTRUCTOR            CdbProperty::CdbProperty(
  3564.     DAOProperty *    pprp,
  3565.     BOOL            bAddRef)    // = FALSE
  3566.     {
  3567.     SetInterface((LPUNKNOWN)pprp, bAddRef);
  3568.     }
  3569.  
  3570. CONSTRUCTOR            CdbProperty::CdbProperty(
  3571.     const CdbProperty &o)
  3572.     {
  3573.     SetInterface(o.GetInterface(TRUE));
  3574.     }
  3575.  
  3576. CdbProperty &        CdbProperty::operator =(
  3577.     const CdbProperty &o)
  3578.     {
  3579.     SetInterface(o.GetInterface(TRUE));
  3580.     return *this;
  3581.     }
  3582.  
  3583. // Properties
  3584. COleVariant            CdbProperty::GetValue(
  3585.     VOID)
  3586.     {
  3587.     DAOProperty *    pprp = (DAOProperty *)GetInterface();
  3588.     COleVariant        v;
  3589.  
  3590.     if (!pprp)
  3591.         return v;
  3592.  
  3593.     DAOMFC_CALL(pprp->get_Value((LPVARIANT)v));
  3594.  
  3595.     return v;
  3596.     }
  3597.  
  3598. VOID                CdbProperty::SetValue(
  3599.     LPVARIANT pv)
  3600.     {
  3601.     DAOProperty *    pprp = (DAOProperty *)GetInterface();
  3602.  
  3603.     DAOMFC_CALL(pprp->put_Value(*pv));
  3604.     }
  3605.  
  3606. CString                CdbProperty::GetName(
  3607.     VOID)
  3608.     {
  3609.     DAOProperty *    pprp = (DAOProperty *)GetInterface();
  3610.     CdbBSTR            bstr;
  3611.  
  3612.     if (!pprp)
  3613.         return (LPCTSTR)NULL;
  3614.  
  3615.     DAOMFC_CALL(pprp->get_Name(bstr));
  3616.  
  3617.     return bstr;
  3618.     }
  3619.  
  3620. VOID                CdbProperty::SetName(
  3621.     LPCTSTR pstrName)
  3622.     {
  3623.     DAOProperty *    pprp = (DAOProperty *)GetInterface();
  3624.  
  3625.     DAOMFC_CALL(pprp->put_Name(STB(pstrName)));
  3626.     }
  3627.  
  3628. SHORT                CdbProperty::GetType(
  3629.     VOID)
  3630.     {
  3631.     DAOProperty *    pprp     = (DAOProperty *)GetInterface();
  3632.     SHORT            s        = 0;
  3633.  
  3634.     if (!pprp)
  3635.         return 0;
  3636.  
  3637.     DAOMFC_CALL(pprp->get_Type(&s));
  3638.  
  3639.     return s;
  3640.     }
  3641.  
  3642. VOID                CdbProperty::SetType(
  3643.     SHORT sType)
  3644.     {
  3645.     DAOProperty *    pprp = (DAOProperty *)GetInterface();
  3646.  
  3647.     DAOMFC_CALL(pprp->put_Type(sType));
  3648.     }
  3649.  
  3650. BOOL                CdbProperty::GetInherited(
  3651.     VOID)
  3652.     {
  3653.     DAOProperty *    pprp    = (DAOProperty *)GetInterface();
  3654.     VARIANT_BOOL    vb        = 0;
  3655.  
  3656.     if (!pprp)
  3657.         return FALSE;
  3658.  
  3659.     DAOMFC_CALL(pprp->get_Inherited(&vb));
  3660.  
  3661.     return (BOOL)vb;
  3662.     }
  3663.  
  3664.  
  3665. /*****************************************************************************
  3666. * CdbParameter
  3667. */
  3668. // Administration
  3669. CONSTRUCTOR            CdbParameter::CdbParameter(
  3670.     VOID)
  3671.     {
  3672.     }
  3673.  
  3674. CONSTRUCTOR            CdbParameter::CdbParameter(
  3675.     DAOParameter *    pprm,
  3676.     BOOL             bAddRef)    // = FALSE
  3677.     {
  3678.     CdbOleObject::SetInterface((LPUNKNOWN)pprm, bAddRef);
  3679.     }
  3680.  
  3681. CONSTRUCTOR            CdbParameter::CdbParameter(
  3682.     const CdbParameter &o)
  3683.     {
  3684.     SetInterface(o.GetInterface(TRUE));
  3685.     }
  3686.  
  3687. CdbParameter &        CdbParameter::operator =(
  3688.     const CdbParameter &o)
  3689.     {
  3690.     SetInterface(o.GetInterface(TRUE));
  3691.     return *this;
  3692.     }
  3693.  
  3694. VOID                CdbParameter::OnInterfaceChange(
  3695.     VOID)
  3696.     {
  3697.     DAOParameter *    pprm    = (DAOParameter *)GetInterface();
  3698.     DAOProperties *    pprps    = NULL;
  3699.  
  3700.     if (pprm)
  3701.         pprm->get_Properties(&pprps);
  3702.  
  3703.     Properties.SetInterface(pprps);
  3704.     }
  3705.  
  3706. // Properties
  3707. CString                CdbParameter::GetName(
  3708.     VOID)
  3709.     {
  3710.     SPROPGET(DAOParameter, get_Name);
  3711.     }
  3712.  
  3713. COleVariant            CdbParameter::GetValue(
  3714.     VOID)
  3715.     {
  3716.     VPROPGET(DAOParameter, get_Value);
  3717.     }
  3718.  
  3719. VOID                CdbParameter::SetValue(
  3720.     LPVARIANT pv)
  3721.     {
  3722.     VPROPSET(DAOParameter, put_Value, pv);
  3723.     }
  3724.  
  3725. SHORT                CdbParameter::GetType(
  3726.     VOID)
  3727.     {
  3728.     WPROPGET(DAOParameter, get_Type);
  3729.     }
  3730.  
  3731. VOID                CdbParameter::SetType(
  3732.     SHORT i)
  3733.     {
  3734.     WPROPSET(DAOParameter, put_Type, i);
  3735.     }
  3736.  
  3737. SHORT                CdbParameter::GetDirection(
  3738.     VOID)
  3739.     {
  3740.     WPROPGET(DAOParameter, get_Direction);
  3741.     }
  3742.  
  3743. VOID                CdbParameter::SetDirection(
  3744.     SHORT i)
  3745.     {
  3746.     WPROPSET(DAOParameter, put_Direction, i);
  3747.     }
  3748.  
  3749. /*****************************************************************************
  3750. * CdbRelation
  3751. */
  3752. // Administration
  3753. CONSTRUCTOR            CdbRelation::CdbRelation(
  3754.     VOID)
  3755.     {
  3756.     }
  3757.  
  3758. CONSTRUCTOR            CdbRelation::CdbRelation(
  3759.     DAORelation *    prl,
  3760.     BOOL             bAddRef)    // = FALSE
  3761.     {
  3762.     CdbOleObject::SetInterface((LPUNKNOWN)prl, bAddRef);
  3763.     }
  3764.  
  3765. CONSTRUCTOR            CdbRelation::CdbRelation(
  3766.     const CdbRelation &o)
  3767.     {
  3768.     SetInterface(o.GetInterface(TRUE));
  3769.     }
  3770.  
  3771. CdbRelation &        CdbRelation::operator =(
  3772.     const CdbRelation &o)
  3773.     {
  3774.     SetInterface(o.GetInterface(TRUE));
  3775.     return *this;
  3776.     }
  3777.  
  3778. VOID                CdbRelation::OnInterfaceChange(
  3779.     VOID)
  3780.     {
  3781.     DAORelation *    prl        = (DAORelation *)GetInterface();
  3782.     DAOProperties *    pprps    = NULL;
  3783.     DAOFields *        pflds    = NULL;
  3784.  
  3785.     if (prl)
  3786.         {
  3787.         prl->get_Properties(&pprps);
  3788.         prl->get_Fields(&pflds);
  3789.         }
  3790.  
  3791.     Properties.SetInterface(pprps);
  3792.     Fields.SetInterface(pflds);
  3793.     }
  3794.  
  3795. // Properties
  3796. CString                CdbRelation::GetName(
  3797.     VOID)
  3798.     {
  3799.     SPROPGET(DAORelation, get_Name);
  3800.     }
  3801.  
  3802. VOID                CdbRelation::SetName(
  3803.     LPCTSTR pstr)
  3804.     {
  3805.     SPROPSET(DAORelation, put_Name, pstr);
  3806.     }
  3807.  
  3808. CString                CdbRelation::GetTable(
  3809.     VOID)
  3810.     {
  3811.     SPROPGET(DAORelation, get_Table);
  3812.     }
  3813.  
  3814. VOID                CdbRelation::SetTable(
  3815.     LPCTSTR pstr)
  3816.     {
  3817.     SPROPSET(DAORelation, put_Table, pstr);
  3818.     }
  3819.  
  3820. CString                CdbRelation::GetForeignTable(
  3821.     VOID)
  3822.     {
  3823.     SPROPGET(DAORelation, get_ForeignTable);
  3824.     }
  3825.  
  3826. VOID                CdbRelation::SetForeignTable(
  3827.     LPCTSTR pstr)
  3828.     {
  3829.     SPROPSET(DAORelation, put_ForeignTable, pstr);
  3830.     }
  3831.  
  3832. LONG                CdbRelation::GetAttributes(
  3833.     VOID)
  3834.     {
  3835.     LPROPGET(DAORelation, get_Attributes);
  3836.     }
  3837.  
  3838. VOID                CdbRelation::SetAttributes(
  3839.     LONG l)
  3840.     {
  3841.     LPROPSET(DAORelation, put_Attributes, l);
  3842.     }
  3843.  
  3844. BOOL                CdbRelation::GetPartialReplica(
  3845.     VOID)
  3846.     {
  3847.     BPROPGET(DAORelation, get_PartialReplica);
  3848.     }
  3849.  
  3850. VOID                CdbRelation::SetPartialReplica(
  3851.     BOOL b)
  3852.     {
  3853.     BPROPSET(DAORelation, put_PartialReplica, b);
  3854.     }
  3855.  
  3856. // Methods
  3857. CdbField            CdbRelation::CreateField(
  3858.     LPCTSTR    pstrName,    // = NULL
  3859.     LONG    lType,        // = -1
  3860.     LONG    lSize)        // = -1
  3861.     {
  3862.     DAORelation *    prl        = (DAORelation *)GetInterface();
  3863.     DAOField *        pfld    = NULL;
  3864.  
  3865.     if (!prl)
  3866.         return (DAOField *)NULL;
  3867.  
  3868.     DAOMFC_CALL(prl->CreateField(STV(pstrName), OLTV(lType), OLTV(lSize), &pfld));
  3869.  
  3870.     return pfld;
  3871.     }
  3872.  
  3873.  
  3874. /*****************************************************************************
  3875. * CdbUser
  3876. */
  3877. // Administration
  3878. CONSTRUCTOR            CdbUser::CdbUser(
  3879.     VOID)
  3880.     {
  3881.     }
  3882.  
  3883. CONSTRUCTOR            CdbUser::CdbUser(
  3884.     DAOUser *    pusr,
  3885.     BOOL         bAddRef)    // = FALSE
  3886.     {
  3887.     CdbOleObject::SetInterface((LPUNKNOWN)pusr, bAddRef);
  3888.     }
  3889.  
  3890. CONSTRUCTOR            CdbUser::CdbUser(
  3891.     const CdbUser &o)
  3892.     {
  3893.     SetInterface(o.GetInterface(TRUE));
  3894.     }
  3895.  
  3896. CdbUser &            CdbUser::operator =(
  3897.     const CdbUser &o)
  3898.     {
  3899.     SetInterface(o.GetInterface(TRUE));
  3900.     return *this;
  3901.     }
  3902.  
  3903. VOID                CdbUser::OnInterfaceChange(
  3904.     VOID)
  3905.     {
  3906.     DAOUser *        pusr     = (DAOUser *)GetInterface();
  3907.     DAOProperties *    pprps    = NULL;
  3908.     DAOGroups *        pgrps    = NULL;
  3909.  
  3910.     if (pusr)
  3911.         {
  3912.         pusr->get_Properties(&pprps);
  3913.         pusr->get_Groups(&pgrps);
  3914.         }
  3915.  
  3916.     Properties.SetInterface(pprps);
  3917.     Groups.SetInterface(pgrps);
  3918.     }
  3919.  
  3920. // Properties
  3921. CString                CdbUser::GetName(
  3922.     VOID)
  3923.     {
  3924.     SPROPGET(DAOUser, get_Name);
  3925.     }
  3926.  
  3927. VOID                CdbUser::SetName(
  3928.     LPCTSTR pstr)
  3929.     {
  3930.     SPROPSET(DAOUser, put_Name, pstr);
  3931.     }
  3932.  
  3933. VOID                CdbUser::SetPID(
  3934.     LPCTSTR pstr)
  3935.     {
  3936.     SPROPSET(DAOUser, put_PID, pstr);
  3937.     }
  3938.  
  3939. VOID                CdbUser::SetPassword(
  3940.     LPCTSTR pstr)
  3941.     {
  3942.     SPROPSET(DAOUser, put_Password, pstr);
  3943.     }
  3944.  
  3945. // Methods
  3946. VOID                CdbUser::NewPassword(
  3947.     LPCTSTR    pstrOld,
  3948.     LPCTSTR    pstrNew)
  3949.     {
  3950.     DAOUser *        pusr     = (DAOUser *)GetInterface();
  3951.  
  3952.     DAOMFC_CALL(pusr->NewPassword(STB(pstrOld), STB(pstrNew)));
  3953.     }
  3954.  
  3955. CdbGroup            CdbUser::CreateGroup(
  3956.     LPCTSTR pstrName,    // = NULL
  3957.     LPCTSTR pstrPID)    // = NULL
  3958.     {
  3959.     DAOUser *        pusr     = (DAOUser *)GetInterface();
  3960.     DAOGroup *        pgrp    = NULL;
  3961.  
  3962.     if (!pusr)
  3963.         return FALSE;
  3964.  
  3965.     DAOMFC_CALL(pusr->CreateGroup(STV(pstrName), STV(pstrPID), &pgrp));
  3966.  
  3967.     return pgrp;
  3968.     }
  3969.  
  3970. /*****************************************************************************
  3971. * CdbGroup
  3972. */
  3973. // Administration
  3974. CONSTRUCTOR            CdbGroup::CdbGroup(
  3975.     VOID)
  3976.     {
  3977.     }
  3978.  
  3979. CONSTRUCTOR            CdbGroup::CdbGroup(
  3980.     DAOGroup *    pgrp,
  3981.     BOOL         bAddRef)    // = FALSE
  3982.     {
  3983.     CdbOleObject::SetInterface((LPUNKNOWN)pgrp, bAddRef);
  3984.     }
  3985.  
  3986. CONSTRUCTOR            CdbGroup::CdbGroup(
  3987.     const CdbGroup &o)
  3988.     {
  3989.     SetInterface(o.GetInterface(TRUE));
  3990.     }
  3991.  
  3992. CdbGroup &            CdbGroup::operator =(
  3993.     const CdbGroup &o)
  3994.     {
  3995.     SetInterface(o.GetInterface(TRUE));
  3996.     return *this;
  3997.     }
  3998.  
  3999. VOID                CdbGroup::OnInterfaceChange(
  4000.     VOID)
  4001.     {
  4002.     DAOGroup *        pgrp     = (DAOGroup *)GetInterface();
  4003.     DAOProperties *    pprps    = NULL;
  4004.     DAOUsers *        pusrs    = NULL;
  4005.  
  4006.     if (pgrp)
  4007.         {
  4008.         pgrp->get_Properties(&pprps);
  4009.         pgrp->get_Users(&pusrs);
  4010.         }
  4011.  
  4012.     Properties.SetInterface(pprps);
  4013.     Users.SetInterface(pusrs);
  4014.     }
  4015.  
  4016. // Properties
  4017. CString                CdbGroup::GetName(
  4018.     VOID)
  4019.     {
  4020.     SPROPGET(DAOGroup, get_Name);
  4021.     }
  4022.  
  4023. VOID                CdbGroup::SetName(
  4024.     LPCTSTR pstr)
  4025.     {
  4026.     SPROPSET(DAOGroup, put_Name, pstr);
  4027.     }
  4028.  
  4029. VOID                CdbGroup::SetPID(
  4030.     LPCTSTR pstr)
  4031.     {
  4032.     SPROPSET(DAOGroup, put_PID, pstr);
  4033.     }
  4034.  
  4035. // Methods
  4036. CdbUser                CdbGroup::CreateUser(
  4037.     LPCTSTR pstrName,        // = NULL
  4038.     LPCTSTR pstrPID,        // = NULL
  4039.     LPCTSTR    pstrPassword)    // = NULL
  4040.     {
  4041.     DAOGroup *        pgrp     = (DAOGroup *)GetInterface();
  4042.     DAOUser *        pusr    = NULL;
  4043.  
  4044.     if (!pgrp)
  4045.         return FALSE;
  4046.  
  4047.     DAOMFC_CALL(pgrp->CreateUser(STV(pstrName), STV(pstrPID), STV(pstrPassword), &pusr));
  4048.  
  4049.     return pusr;
  4050.     }
  4051.  
  4052.  
  4053. /*****************************************************************************
  4054. * CdbDocument
  4055. */
  4056. // Administration
  4057. CONSTRUCTOR            CdbDocument::CdbDocument(
  4058.     VOID)
  4059.     {
  4060.     }
  4061.  
  4062. CONSTRUCTOR            CdbDocument::CdbDocument(
  4063.     DAODocument *    pdoc,
  4064.     BOOL             bAddRef)    // = FALSE
  4065.     {
  4066.     CdbOleObject::SetInterface((LPUNKNOWN)pdoc, bAddRef);
  4067.     }
  4068.  
  4069. CONSTRUCTOR            CdbDocument::CdbDocument(
  4070.     const CdbDocument &o)
  4071.     {
  4072.     SetInterface(o.GetInterface(TRUE));
  4073.     }
  4074.  
  4075. CdbDocument &        CdbDocument::operator =(
  4076.     const CdbDocument &o)
  4077.     {
  4078.     SetInterface(o.GetInterface(TRUE));
  4079.     return *this;
  4080.     }
  4081.  
  4082. VOID                CdbDocument::OnInterfaceChange(
  4083.     VOID)
  4084.     {
  4085.     DAODocument *    pdoc    = (DAODocument *)GetInterface();
  4086.     DAOProperties *    pprps    = NULL;
  4087.  
  4088.     if (pdoc)
  4089.         {
  4090.         pdoc->get_Properties(&pprps);
  4091.         }
  4092.  
  4093.     Properties.SetInterface(pprps);
  4094.     }
  4095.  
  4096. // Properties
  4097. CString                CdbDocument::GetName(
  4098.     VOID)
  4099.     {
  4100.     SPROPGET(DAODocument, get_Name);
  4101.     }
  4102.  
  4103. CString                CdbDocument::GetOwner(
  4104.     VOID)
  4105.     {
  4106.     SPROPGET(DAODocument, get_Owner);
  4107.     }
  4108.  
  4109. VOID                CdbDocument::SetOwner(
  4110.     LPCTSTR pstr)
  4111.     {
  4112.     SPROPSET(DAODocument, put_Owner, pstr);
  4113.     }
  4114.  
  4115. CString                CdbDocument::GetContainer(
  4116.     VOID)
  4117.     {
  4118.     SPROPGET(DAODocument, get_Container);
  4119.     }
  4120.  
  4121. CString                CdbDocument::GetUserName(
  4122.     VOID)
  4123.     {
  4124.     SPROPGET(DAODocument, get_UserName);
  4125.     }
  4126.  
  4127. VOID                CdbDocument::SetUserName(
  4128.     LPCTSTR pstr)
  4129.     {
  4130.     SPROPSET(DAODocument, put_UserName, pstr);
  4131.     }
  4132.  
  4133. LONG                CdbDocument::GetPermissions(
  4134.     VOID)
  4135.     {
  4136.     LPROPGET(DAODocument, get_Permissions);
  4137.     }
  4138.  
  4139. VOID                CdbDocument::SetPermissions(
  4140.     LONG l)
  4141.     {
  4142.     LPROPSET(DAODocument, put_Permissions, l);
  4143.     }
  4144.  
  4145. COleDateTime            CdbDocument::GetDateCreated(
  4146.     VOID)
  4147.     {
  4148.     DPROPGET(DAODocument, get_DateCreated);
  4149.     }
  4150.  
  4151. COleDateTime            CdbDocument::GetLastUpdated(
  4152.     VOID)
  4153.     {
  4154.     DPROPGET(DAODocument, get_LastUpdated);
  4155.     }
  4156.  
  4157. LONG            CdbDocument::GetAllPermissions(
  4158.     VOID)
  4159.     {
  4160.     LPROPGET(DAODocument, get_AllPermissions);
  4161.     }
  4162.  
  4163. //Methods
  4164. CdbProperty            CdbDocument::CreateProperty(
  4165.     LPCTSTR        pstrName,    // = NULL
  4166.     LONG        lType,        // = -1
  4167.     LPVARIANT    pvValue,    // = NULL
  4168.     BOOL        bDDL)        // = FALSE
  4169.     {
  4170.     DAODocument *    pdoc    = (DAODocument *)GetInterface();
  4171.     DAOProperty *    pprp    = NULL;
  4172.  
  4173.     if (!pdoc)
  4174.         return (DAOProperty *)NULL;
  4175.  
  4176.     DAOMFC_CALL(pdoc->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
  4177.  
  4178.     return pprp;
  4179.     }
  4180.  
  4181.  
  4182. /*****************************************************************************
  4183. * CdbContainer
  4184. */
  4185. // Administration
  4186. CONSTRUCTOR            CdbContainer::CdbContainer(
  4187.     VOID)
  4188.     {
  4189.     }
  4190.  
  4191. CONSTRUCTOR            CdbContainer::CdbContainer(
  4192.     DAOContainer *    pctn,
  4193.     BOOL            bAddRef)    // = FALSE
  4194.     {
  4195.     CdbOleObject::SetInterface((LPUNKNOWN)pctn, bAddRef);
  4196.     }
  4197.  
  4198. CONSTRUCTOR            CdbContainer::CdbContainer(
  4199.     const CdbContainer &o)
  4200.     {
  4201.     SetInterface(o.GetInterface(TRUE));
  4202.     }
  4203.  
  4204. CdbContainer &        CdbContainer::operator =(
  4205.     const CdbContainer &o)
  4206.     {
  4207.     SetInterface(o.GetInterface(TRUE));
  4208.     return *this;
  4209.     }
  4210.  
  4211. VOID                CdbContainer::OnInterfaceChange(
  4212.     VOID)
  4213.     {
  4214.     DAOContainer *    pctn    = (DAOContainer *)GetInterface();
  4215.     DAOProperties *    pprps    = NULL;
  4216.     DAODocuments *    pdocs    = NULL;
  4217.  
  4218.     if (pctn)
  4219.         {
  4220.         pctn->get_Properties(&pprps);
  4221.         pctn->get_Documents(&pdocs);
  4222.         }
  4223.  
  4224.     Properties.SetInterface(pprps);
  4225.     Documents.SetInterface(pdocs);
  4226.     }
  4227.  
  4228. // Properties
  4229. CString                CdbContainer::GetName(
  4230.     VOID)
  4231.     {
  4232.     SPROPGET(DAOContainer, get_Name);
  4233.     }
  4234.  
  4235. CString                CdbContainer::GetOwner(
  4236.     VOID)
  4237.     {
  4238.     SPROPGET(DAOContainer, get_Owner);
  4239.     }
  4240.  
  4241. VOID                CdbContainer::SetOwner(
  4242.     LPCTSTR pstr)
  4243.     {
  4244.     SPROPSET(DAOContainer, put_Owner, pstr);
  4245.     }
  4246.  
  4247. CString                CdbContainer::GetUserName(
  4248.     VOID)
  4249.     {
  4250.     SPROPGET(DAOContainer, get_UserName);
  4251.     }
  4252.  
  4253. VOID                CdbContainer::SetUserName(
  4254.     LPCTSTR pstr)
  4255.     {
  4256.     SPROPSET(DAOContainer, put_UserName, pstr);
  4257.     }
  4258.  
  4259. LONG                CdbContainer::GetPermissions(
  4260.     VOID)
  4261.     {
  4262.     LPROPGET(DAOContainer, get_Permissions);
  4263.     }
  4264.  
  4265. VOID                CdbContainer::SetPermissions(
  4266.     LONG l)
  4267.     {
  4268.     LPROPSET(DAOContainer, put_Permissions, l);
  4269.     }
  4270.  
  4271. BOOL                CdbContainer::GetInherit(
  4272.     VOID)
  4273.     {
  4274.     BPROPGET(DAOContainer, get_Inherit);
  4275.     }
  4276.  
  4277. VOID                CdbContainer::SetInherit(
  4278.     BOOL b)
  4279.     {
  4280.     BPROPSET(DAOContainer, put_Inherit, b);
  4281.     }
  4282.  
  4283. LONG            CdbContainer::GetAllPermissions(
  4284.     VOID)
  4285.     {
  4286.     LPROPGET(DAOContainer, get_AllPermissions);
  4287.     }
  4288.  
  4289. /*****************************************************************************
  4290. * CdbIndexFields (special case for index fields)
  4291. */
  4292. CdbField            CdbIndexFields::Item(
  4293.     LPCTSTR pstr)
  4294.     {
  4295.     DAOIndexFields *    pflds    = (DAOIndexFields *)GetInterface();
  4296.     VARIANT                v;
  4297.     DAOField *            pfld    = NULL;
  4298.  
  4299.     if (!pflds)
  4300.         return (DAOField *)NULL;
  4301.  
  4302.     VariantInit(&v);
  4303.     DAOMFC_CALL(pflds->get_Item(STV(pstr), &v));
  4304.  
  4305.     if (v.vt == VT_DISPATCH)
  4306.         {
  4307.         v.pdispVal->QueryInterface(dbIID_IDAOField, (LPVOID *)&pfld);
  4308.         v.pdispVal->Release();
  4309.         }
  4310.  
  4311.     return pfld;
  4312.     }
  4313.  
  4314. CdbField            CdbIndexFields::Item(
  4315.     LONG i)
  4316.     {
  4317.     DAOIndexFields *    pflds    = (DAOIndexFields *)GetInterface();
  4318.     VARIANT                v;
  4319.     DAOField *            pfld    = NULL;
  4320.  
  4321.     if (!pflds)
  4322.         return (DAOField *)NULL;
  4323.  
  4324.     VariantInit(&v);
  4325.     DAOMFC_CALL(pflds->get_Item(LTV(i), &v));
  4326.  
  4327.     if (v.vt == VT_DISPATCH)
  4328.         {
  4329.         v.pdispVal->QueryInterface(dbIID_IDAOField, (LPVOID *)&pfld);
  4330.         v.pdispVal->Release();
  4331.         }
  4332.  
  4333.     return pfld;
  4334.     }
  4335.  
  4336. CdbObject            CdbIndexFields::ObItem(
  4337.     LPCTSTR pstr)
  4338.     {
  4339.     DAOIndexFields *    pflds    = (DAOIndexFields *)GetInterface();
  4340.     VARIANT                v;
  4341.     DAOField *            pfld    = NULL;
  4342.  
  4343.     if (!pflds)
  4344.         return (DAOFields *)NULL;
  4345.  
  4346.     VariantInit(&v);
  4347.     DAOMFC_CALL(pflds->get_Item(STV(pstr), &v));
  4348.  
  4349.     if (v.vt == VT_DISPATCH)
  4350.         {
  4351.         v.pdispVal->QueryInterface(dbIID_IDAOField, (LPVOID *)&pfld);
  4352.         v.pdispVal->Release();
  4353.         }
  4354.  
  4355.     return (LPUNKNOWN)pfld;
  4356.     }
  4357.  
  4358. CdbObject            CdbIndexFields::ObItem(
  4359.     LONG i)
  4360.     {
  4361.     DAOIndexFields *    pflds    = (DAOIndexFields *)GetInterface();
  4362.     VARIANT                v;
  4363.     DAOField *            pfld    = NULL;
  4364.  
  4365.     if (!pflds)
  4366.         return (DAOFields *)NULL;
  4367.  
  4368.     VariantInit(&v);
  4369.     DAOMFC_CALL(pflds->get_Item(LTV(i), &v));
  4370.  
  4371.     if (v.vt == VT_DISPATCH)
  4372.         {
  4373.         v.pdispVal->QueryInterface(dbIID_IDAOField, (LPVOID *)&pfld);
  4374.         v.pdispVal->Release();
  4375.         }
  4376.  
  4377.     return (LPUNKNOWN)pfld;
  4378.     }
  4379.  
  4380.  
  4381.  
  4382. /*****************************************************************************
  4383. * CdbBSTR
  4384. */
  4385. CONSTRUCTOR            CdbBSTR::CdbBSTR(
  4386.     BSTR    b)    // = NULL
  4387.     {
  4388.     m_bstr = b;
  4389.     }
  4390.  
  4391. DESTRUCTOR            CdbBSTR::~CdbBSTR(
  4392.     VOID)
  4393.     {
  4394.     if (m_bstr)
  4395.         SysFreeString(m_bstr);
  4396.     }
  4397.  
  4398.                     CdbBSTR::operator BSTR *(
  4399.     VOID)
  4400.     {
  4401.     return &m_bstr;
  4402.     }
  4403.  
  4404.                     CdbBSTR::operator LPCTSTR(
  4405.     VOID)
  4406.     {
  4407.     return (LPCTSTR)m_bstr;
  4408.     }
  4409.  
  4410. HRESULT                        CdbWideFromAnsi(
  4411.     LPSTR            pstr,
  4412.     unsigned int    cb,
  4413.     BSTR *            pbstr)
  4414.     {
  4415.     BSTR            bstrNew;
  4416.  
  4417.     if (!(bstrNew = SysAllocStringLen(NULL, cb)))
  4418.         return ResultFromScode(E_OUTOFMEMORY);
  4419.     
  4420.     // Convert from ANSI to WIDE if char.s exist
  4421.     if (cb && !(cb = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pstr,
  4422.         cb, (LPWSTR)bstrNew, cb)))
  4423.         {
  4424.         SysFreeString(bstrNew);
  4425.         return ResultFromScode(E_OUTOFMEMORY);
  4426.         }
  4427.  
  4428.     // Make sure it's NULL terminated
  4429.     ((LPWSTR)(bstrNew))[cb] = L'\0';
  4430.  
  4431.     *pbstr = bstrNew;
  4432.  
  4433.     return NOERROR;
  4434.     }
  4435.