home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / MS_DAO.SDK / DISK4 / DAOSDK.1 / dbdao.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-20  |  67.8 KB  |  3,613 lines

  1. /************************************************************************
  2. **    D B D A O . C P P                                                    *
  3. **                                                                        *
  4. *************************************************************************
  5. ** Copyright (C) 1995 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.                     CdbBookmark::operator LPSAFEARRAY(
  49.     VOID)
  50.     {
  51.     return (vt&VT_ARRAY?parray:NULL);
  52.     }
  53.  
  54. /*****************************************************************************
  55. * CdbOleObject
  56. */
  57. CONSTRUCTOR            CdbOleObject::CdbOleObject(
  58.     VOID)
  59.     {
  60.     m_punkInterface = NULL;
  61.     }
  62.  
  63. CdbOleObject &        CdbOleObject::operator =(
  64.     CdbOleObject &o)
  65.     {
  66.     SetInterface(o.m_punkInterface, TRUE);
  67.     return *this;
  68.     }
  69.  
  70. DESTRUCTOR            CdbOleObject::~CdbOleObject(
  71.     VOID)
  72.     {
  73.  
  74.     if (m_punkInterface)
  75.         m_punkInterface->Release();
  76.     }
  77.  
  78. BOOL                CdbOleObject::StartOLE(
  79.     )
  80.     {
  81.     HRESULT    hr;
  82.  
  83.     DAOMFC_CALL(hr=CoInitialize(NULL));
  84.  
  85.     return SUCCEEDED(hr);
  86.     }
  87.  
  88. VOID                CdbOleObject::SetInterface(
  89.     LPUNKNOWN    punk,
  90.     BOOL        bAddRef)    // = FALSE
  91.     {
  92.     // Get rid of existing interface, if we have one
  93.     if (m_punkInterface)
  94.         m_punkInterface->Release();
  95.  
  96.     // Addref new interface so we have a valid reference
  97.     if (bAddRef && punk)
  98.         punk->AddRef();
  99.  
  100.     m_punkInterface = punk;
  101.     OnInterfaceChange();
  102.     }
  103.  
  104. VOID                CdbOleObject::SetInterface(
  105.     REFIID    riidClass,
  106.     REFIID    riidInterface)
  107.     {
  108.     LPUNKNOWN    punk;
  109.  
  110.     if (!StartOLE())
  111.         return;
  112.  
  113.     DAOMFC_CALL(CoCreateInstance(riidClass, NULL, CLSCTX_INPROC_SERVER, riidInterface, (LPVOID *)&punk));
  114.  
  115.     SetInterface(punk);
  116.     }
  117.  
  118. VOID                CdbOleObject::SetInterfaceLic(
  119.     REFIID    riidClass,
  120.     REFIID    riidInterface)
  121.     {
  122.     LPUNKNOWN    punk;
  123.     BSTR        m_bstrKey = NULL;
  124.     LPCLASSFACTORY2 pClassFactory2 = NULL;
  125.  
  126.     if (!StartOLE())
  127.         return;
  128.  
  129. #if _MSC_VER >= 1000
  130.     m_bstrKey = SysAllocString(CdbWide((LPSTR)szKEY));
  131. #else
  132.     m_bstrKey = SysAllocString(_T(szKEY));
  133. #endif
  134.  
  135.     DAOMFC_CALL(CoGetClassObject(riidClass, CLSCTX_INPROC_SERVER, NULL, IID_IClassFactory2, (void**)&pClassFactory2));
  136.     
  137.     ASSERT(pClassFactory2 != NULL);
  138.  
  139.     DAOMFC_CALL(pClassFactory2->CreateInstanceLic(NULL, NULL, riidInterface, m_bstrKey,(LPVOID *)&punk));
  140.         
  141.     if (NULL!=m_bstrKey)
  142.         SysFreeString(m_bstrKey);
  143.  
  144.     SetInterface(punk);
  145.     }
  146.  
  147.  
  148. LPUNKNOWN            CdbOleObject::GetInterface(
  149.     BOOL    bAddRef,                // = FALSE
  150.     BOOL    bThrowException) const    // = TRUE
  151.     {
  152.     if (!m_punkInterface)
  153.         {
  154.         // Oops! The OLE interface has not been set yet a request is
  155.         // being made to access the interface!
  156.  
  157.         if (bThrowException)
  158.             {
  159.             // First: Set the rich error info.
  160.             #if _MSC_VER >= 1000
  161.             SetRichErrorInfo(L"DBDAO", L"Object OLE interface not set.", NULL, 0L);
  162.             #endif
  163.             // Second: Throw an exception.
  164.             DAOMFC_CALL(E_FAIL);
  165.             }
  166.         else
  167.             return NULL;
  168.         }
  169.  
  170.     if (bAddRef)
  171.         m_punkInterface->AddRef();
  172.  
  173.     return m_punkInterface;
  174.     }
  175.  
  176. VOID                CdbOleObject::OnInterfaceChange(
  177.     VOID)
  178.     {
  179.     // By default do nothing on interface change
  180.     }
  181.  
  182. VOID                CdbOleObject::SetRichErrorInfo(
  183.     LPOLESTR    pstrSource,
  184.     LPOLESTR    pstrDescription,
  185.     LPOLESTR    pstrHelpFile,
  186.     ULONG        ulHelpID) const
  187.     {
  188.     ICreateErrorInfo *    pcei;
  189.     IErrorInfo *        pei;
  190.  
  191.     if (FAILED(CreateErrorInfo(&pcei)))
  192.         return;
  193.  
  194.     if (FAILED(pcei->QueryInterface(IID_IErrorInfo, (LPVOID *)&pei)))
  195.         {
  196.         pcei->Release();
  197.         return;
  198.         }
  199.  
  200.     pcei->SetGUID(IID_NULL);
  201.  
  202.     if (pstrSource)
  203.         pcei->SetSource(pstrSource);
  204.     if (pstrDescription)
  205.         pcei->SetDescription(pstrDescription);
  206.     if (pstrHelpFile)
  207.         pcei->SetHelpFile(pstrHelpFile);
  208.  
  209.     pcei->SetHelpContext(ulHelpID);
  210.  
  211.     SetErrorInfo((DWORD)0, pei);
  212.  
  213.     pei->Release();
  214.     pcei->Release();
  215.     }
  216.  
  217.  
  218. /*****************************************************************************
  219. * CdbObject
  220. */
  221. CONSTRUCTOR            CdbObject::CdbObject(
  222.     VOID)
  223.     {
  224.     }
  225.  
  226. CONSTRUCTOR            CdbObject::CdbObject(
  227.     LPUNKNOWN    punk,
  228.     BOOL        bAddRef)    // = FALSE
  229.     {
  230.     SetInterface(punk, bAddRef);
  231.     }
  232.  
  233. CString                CdbObject::GetName(
  234.     VOID)
  235.     {
  236.      #if _MSC_VER >= 1000
  237.      SetRichErrorInfo(L"DBDAO", L"Method not supported", NULL, 0);
  238.     #endif
  239.     DAOMFC_CALL(E_FAIL);
  240.     return (LPCTSTR)NULL;
  241.     }
  242.  
  243. VOID                CdbObject::SetName(
  244.     LPCTSTR pstr)
  245.     {
  246.     UNREFERENCED_PARAMETER(pstr);
  247.     #if _MSC_VER >= 1000
  248.     SetRichErrorInfo(L"DBDAO", L"Method not supported", NULL, 0);
  249.     #endif
  250.     DAOMFC_CALL(E_FAIL);
  251.     }
  252.  
  253. /*****************************************************************************
  254. * CdbStaticCollection
  255. */
  256. // Methods
  257. CdbObject        CdbStaticCollection::ObItem(
  258.     LONG i)
  259.     {
  260.     DAOMFCSCollection *    pcol = (DAOMFCSCollection *)GetInterface();
  261.     LPUNKNOWN            pint = NULL;
  262.  
  263.     if (!pcol)
  264.         return (LPUNKNOWN)NULL;
  265.  
  266.     DAOMFC_CALL(pcol->get_Item(LTV(i), &pint));
  267.  
  268.     return pint;
  269.     }
  270.  
  271. CdbObject        CdbStaticCollection::ObItem(
  272.     LPCTSTR pstr)
  273.     {
  274.     DAOMFCSCollection *    pcol = (DAOMFCSCollection *)GetInterface();
  275.     LPUNKNOWN            pint = NULL;
  276.  
  277.     if (!pcol)
  278.         return (LPUNKNOWN)NULL;
  279.  
  280.     DAOMFC_CALL(pcol->get_Item(STV(pstr), &pint));
  281.  
  282.     return pint;
  283.     }
  284.  
  285. LONG            CdbStaticCollection::GetCount(
  286.     VOID)
  287.     {
  288.     DAOMFCSCollection *    pcol = (DAOMFCSCollection *)GetInterface();
  289.     SHORT                s        = 0;
  290.  
  291.     if (!pcol)
  292.         return 0;
  293.  
  294.     DAOMFC_CALL(pcol->get_Count(&s));
  295.  
  296.     return (LONG)s;
  297.     }
  298.  
  299. VOID            CdbStaticCollection::ObAppend(
  300.     CdbObject &o)
  301.     {
  302.     UNREFERENCED_PARAMETER(o);
  303.     }
  304.  
  305. VOID            CdbStaticCollection::Delete(
  306.     LPCTSTR pstr)
  307.     {
  308.     UNREFERENCED_PARAMETER(pstr);
  309.     }
  310.  
  311. VOID            CdbStaticCollection::Refresh(
  312.     VOID)
  313.     {
  314.     DAOMFCSCollection *    pcol    = (DAOMFCSCollection *)GetInterface();
  315.  
  316.     DAOMFC_CALL(pcol->Refresh());
  317.     }
  318.  
  319. /*****************************************************************************
  320. * CdbDynamicCollection
  321. */
  322. // Methods
  323. CdbObject        CdbDynamicCollection::ObItem(
  324.     LONG i)
  325.     {
  326.     DAOMFCDCollection *    pcol = (DAOMFCDCollection *)GetInterface();
  327.     LPUNKNOWN            pint = NULL;
  328.  
  329.     if (!pcol)
  330.         return (LPUNKNOWN)NULL;
  331.  
  332.     DAOMFC_CALL(pcol->get_Item(LTV(i), &pint));
  333.  
  334.     return pint;
  335.     }
  336.  
  337. CdbObject        CdbDynamicCollection::ObItem(
  338.     LPCTSTR pstr)
  339.     {
  340.     DAOMFCDCollection *    pcol = (DAOMFCDCollection *)GetInterface();
  341.     LPUNKNOWN            pint = NULL;
  342.  
  343.     if (!pcol)
  344.         return (LPUNKNOWN)NULL;
  345.  
  346.     DAOMFC_CALL(pcol->get_Item(STV(pstr), &pint));
  347.  
  348.     return pint;
  349.     }
  350.  
  351. LONG            CdbDynamicCollection::GetCount(
  352.     VOID)
  353.     {
  354.     DAOMFCDCollection *    pcol = (DAOMFCDCollection *)GetInterface();
  355.     SHORT                s        = 0;
  356.  
  357.     if (!pcol)
  358.         return 0;
  359.  
  360.     DAOMFC_CALL(pcol->get_Count(&s));
  361.  
  362.     return (LONG)s;
  363.     }
  364.  
  365. VOID            CdbDynamicCollection::ObAppend(
  366.     CdbObject &o)
  367.     {
  368.     DAOMFCDCollection *    pcol    = (DAOMFCDCollection *)GetInterface();
  369.     LPDISPATCH    pdisp            = (LPDISPATCH)o.GetInterface();
  370.  
  371.     if (!pdisp)
  372.         return;
  373.  
  374.     DAOMFC_CALL(pcol->Append(pdisp));
  375.     }
  376.  
  377. VOID            CdbDynamicCollection::Delete(
  378.     LPCTSTR pstr)
  379.     {
  380.     DAOMFCDCollection *    pcol    = (DAOMFCDCollection *)GetInterface();
  381.  
  382.     DAOMFC_CALL(pcol->Delete(STB(pstr)));
  383.     }
  384.  
  385. VOID            CdbDynamicCollection::Refresh(
  386.     VOID)
  387.     {
  388.     DAOMFCDCollection *    pcol    = (DAOMFCDCollection *)GetInterface();
  389.  
  390.     DAOMFC_CALL(pcol->Refresh());
  391.     }
  392.  
  393.  
  394. /*****************************************************************************
  395. * Collection implementations
  396. */
  397. DAOMFC_STATIC_COLLECTION_IMPL(CdbErrors, CdbError, DAOErrors, DAOError)
  398. DAOMFC_STATIC_COLLECTION_IMPL(CdbDatabases, CdbDatabase, DAODatabases, DAODatabase)
  399. DAOMFC_STATIC_COLLECTION_IMPL(CdbRecordsets, CdbRecordset, DAORecordsets, DAORecordset)
  400. DAOMFC_STATIC_COLLECTION_IMPL(CdbParameters, CdbParameter, DAOParameters, DAOParameter)
  401. DAOMFC_STATIC_COLLECTION_IMPL(CdbDocuments, CdbDocument, DAODocuments, DAODocument)
  402. DAOMFC_STATIC_COLLECTION_IMPL(CdbContainers, CdbContainer, DAOContainers, DAOContainer)
  403.  
  404. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbProperties, CdbProperty, DAOProperties, DAOProperty)
  405. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbWorkspaces, CdbWorkspace, DAOWorkspaces, DAOWorkspace)
  406. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbFields, CdbField, DAOFields, DAOField)
  407. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbQueryDefs, CdbQueryDef, DAOQueryDefs, DAOQueryDef)
  408. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbTableDefs, CdbTableDef, DAOTableDefs, DAOTableDef)
  409. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbIndexes, CdbIndex, DAOIndexes, DAOIndex)
  410. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbRelations, CdbRelation, DAORelations, DAORelation)
  411. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbUsers, CdbUser, DAOUsers, DAOUser)
  412. DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbGroups, CdbGroup, DAOGroups, DAOGroup)
  413.  
  414. /*****************************************************************************
  415. * CdbLastOLEError
  416. *
  417. * NOTE:    This object is meant to be used inside of exception handlers so
  418. *        exceptions should not be raised by these member functions.
  419. */
  420. CONSTRUCTOR                CdbLastOLEError::CdbLastOLEError(
  421.     VOID)
  422.     {
  423.     IErrorInfo *    pei = NULL;
  424.  
  425.     GetErrorInfo(0L, &pei);
  426.  
  427.     CdbOleObject::SetInterface((LPUNKNOWN)pei);
  428.     }
  429.  
  430. CString                    CdbLastOLEError::GetSource(
  431.     VOID)
  432.     {
  433.     IErrorInfo *    pei = (IErrorInfo *)GetInterface(FALSE, FALSE);
  434.     CdbBSTR            bstr;
  435.  
  436.     if (!pei)
  437.         return (LPOLESTR)NULL;
  438.  
  439.     pei->GetSource(bstr);
  440.  
  441.     return *((BSTR *)bstr);
  442.     }
  443.  
  444. CString                    CdbLastOLEError::GetDescription(
  445.     VOID)
  446.     {
  447.     IErrorInfo *    pei = (IErrorInfo *)GetInterface(FALSE, FALSE);
  448.     CdbBSTR            bstr;
  449.  
  450.     if (!pei)
  451.         return (LPOLESTR)NULL;
  452.  
  453.     pei->GetDescription(bstr);
  454.  
  455.     return *((BSTR *)bstr);
  456.     }
  457.  
  458. CString                    CdbLastOLEError::GetHelpFile(
  459.     VOID)
  460.     {
  461.     IErrorInfo *    pei = (IErrorInfo *)GetInterface(FALSE, FALSE);
  462.     CdbBSTR            bstr;
  463.  
  464.     if (!pei)
  465.         return (LPOLESTR)NULL;
  466.  
  467.     pei->GetHelpFile(bstr);
  468.  
  469.     return *((BSTR *)bstr);
  470.     }
  471.  
  472. DWORD                    CdbLastOLEError::GetHelpContext(
  473.     VOID)
  474.     {
  475.     IErrorInfo *    pei = (IErrorInfo *)GetInterface(FALSE, FALSE);
  476.     DWORD            dw    = 0;
  477.  
  478.     if (!pei)
  479.         return 0;
  480.  
  481.     pei->GetHelpContext(&dw);
  482.  
  483.     return dw;
  484.     }
  485.  
  486. /*****************************************************************************
  487. * CdbDBEngine
  488. */
  489. // Administration
  490. CONSTRUCTOR            CdbDBEngine::CdbDBEngine(
  491.     DAODBEngine *    peng,
  492.     BOOL            bAddRef)    // = FALSE
  493.     {
  494.     m_bStarted = TRUE;
  495.     CdbOleObject::SetInterface((LPUNKNOWN)peng, bAddRef);
  496.     }
  497.  
  498. CONSTRUCTOR            CdbDBEngine::CdbDBEngine(
  499.     BOOL    bPrivate,        // = FALSE
  500.     BOOL    bStart,            // = TRUE
  501.     LPCTSTR pstrIniPath,    // = NULL
  502.     LPCTSTR pstrDefUser,    // = NULL
  503.     LPCTSTR pstrDefPW)        // = NULL
  504.     {
  505.     m_bStarted = FALSE;
  506.  
  507.     CdbOleObject::SetInterfaceLic(bPrivate?CLSID_CDAOPrivDBEngine:CLSID_CDAODBEngine,dbIID_IDAODBEngine);
  508.                                                                                   
  509.     if (pstrIniPath)
  510.         SetIniPath(pstrIniPath);
  511.     if (pstrDefUser)
  512.         SetDefaultUser(pstrDefUser);
  513.     if (pstrDefPW)
  514.         SetDefaultPassword(pstrDefPW);
  515.  
  516.     if (bStart)
  517.         Start();
  518.  
  519.     }
  520.  
  521. CONSTRUCTOR            CdbDBEngine::CdbDBEngine(
  522.     const CdbDBEngine &o)
  523.     {
  524.     SetInterface(o.GetInterface(TRUE));
  525.     }
  526.  
  527. CdbDBEngine &        CdbDBEngine::operator =(
  528.     const CdbDBEngine &o)
  529.     {
  530.     SetInterface(o.GetInterface(TRUE));
  531.     return *this;
  532.     }
  533.  
  534. VOID                CdbDBEngine::OnInterfaceChange(
  535.     VOID)
  536.     {
  537.     DAODBEngine    *        peng    = (DAODBEngine *)GetInterface();
  538.     DAOProperties *        pprps    = NULL;
  539.     DAOWorkspaces *        pwrks    = NULL;
  540.     DAOErrors *            perrs    = NULL;
  541.  
  542.     if (peng && m_bStarted)
  543.         {
  544.         peng->get_Properties(&pprps);
  545.         peng->get_Workspaces(&pwrks);
  546.         peng->get_Errors(&perrs);
  547.         }
  548.  
  549.     Properties.SetInterface(pprps);
  550.     Workspaces.SetInterface(pwrks);
  551.     Errors.SetInterface(perrs);
  552.     }
  553.  
  554. VOID                CdbDBEngine::Start(
  555.     VOID)
  556.     {
  557.     // If not started then start and setup collections
  558.     if (!m_bStarted)
  559.         {
  560.         m_bStarted = TRUE;
  561.         OnInterfaceChange();
  562.         }
  563.     }
  564.  
  565. // Properties
  566. VOID                CdbDBEngine::SetDefaultPassword(
  567.     LPCTSTR    pstr)
  568.     {
  569.     SPROPSET(DAODBEngine, put_DefaultPassword, pstr);    
  570.     }
  571.  
  572. VOID                CdbDBEngine::SetDefaultUser(
  573.     LPCTSTR    pstr)
  574.     {
  575.     SPROPSET(DAODBEngine, put_DefaultUser, pstr);
  576.     }
  577.  
  578. VOID                CdbDBEngine::SetIniPath(
  579.     LPCTSTR    pstr)
  580.     {
  581.     SPROPSET(DAODBEngine, put_IniPath, pstr);
  582.     }
  583.  
  584. CString                CdbDBEngine::GetIniPath(
  585.     VOID)
  586.     {
  587.     SPROPGET(DAODBEngine, get_IniPath);
  588.     }
  589.  
  590. VOID                CdbDBEngine::SetLoginTimeout(
  591.     SHORT    s)
  592.     {
  593.     WPROPSET(DAODBEngine, put_LoginTimeout, s);
  594.     }
  595.  
  596. SHORT                CdbDBEngine::GetLoginTimeout(
  597.     VOID)
  598.     {
  599.     WPROPGET(DAODBEngine, get_LoginTimeout);
  600.     }
  601.  
  602. CString                CdbDBEngine::GetVersion(
  603.     VOID)
  604.     {
  605.     SPROPGET(DAODBEngine, get_Version);
  606.     }
  607.  
  608. CString                CdbDBEngine::GetSystemDB(
  609.     VOID)
  610.     {
  611.     SPROPGET(DAODBEngine, get_SystemDB);
  612.     }
  613.  
  614. VOID                CdbDBEngine::SetSystemDB(
  615.     LPCTSTR    pstr)
  616.     {
  617.     SPROPSET(DAODBEngine, put_SystemDB, pstr);    
  618.     }
  619.  
  620. // Methods
  621. CdbWorkspace         CdbDBEngine::CreateWorkspace(
  622.     LPCTSTR    pstrName,
  623.     LPCTSTR    pstrUser,
  624.     LPCTSTR    pstrPassword)
  625.     {
  626.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  627.     DAOWorkspace *    pwrk    = NULL;
  628.  
  629.     if (!peng)
  630.         return (DAOWorkspace *)NULL;
  631.  
  632.     DAOMFC_CALL(peng->CreateWorkspace(STB(pstrName), STB(pstrUser), STB(pstrPassword), &pwrk));
  633.  
  634.     return pwrk;
  635.     }
  636.  
  637. VOID                CdbDBEngine::CompactDatabase(
  638.     LPCTSTR    pstrOldDatabase,
  639.     LPCTSTR    pstrNewDatabase,
  640.     LPCTSTR pstrDstConnect, // = NULL
  641.     LONG    lOptions, // = -1
  642.     LPCTSTR pstrSrcConnect)// = NULL
  643.     {
  644.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  645.  
  646.     DAOMFC_CALL(peng->CompactDatabase(STB(pstrOldDatabase), 
  647.         STB(pstrNewDatabase), 
  648.         STV(pstrDstConnect),
  649.         OLTV(lOptions),
  650.         STV(pstrSrcConnect)));
  651.     }
  652.  
  653. VOID                CdbDBEngine::RepairDatabase(
  654.     LPCTSTR pstrDatabase)
  655.     {
  656.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  657.  
  658.     DAOMFC_CALL(peng->RepairDatabase(STB(pstrDatabase)));
  659.     }
  660.  
  661. VOID                CdbDBEngine::RegisterDatabase(
  662.     LPCTSTR    pstrDatabase,
  663.     LPCTSTR    pstrDriver,
  664.     BOOL    bSilent,
  665.     LPCTSTR    pstrAttributes)
  666.     {
  667.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  668.  
  669.     DAOMFC_CALL(peng->RegisterDatabase(STB(pstrDatabase), STB(pstrDriver), BTB(bSilent), STB(pstrAttributes)));
  670.     }
  671.  
  672. VOID                CdbDBEngine::Idle(
  673.     LONG lOptions)    // = -1
  674.     {
  675.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  676.  
  677.     DAOMFC_CALL(peng->Idle(OLTV(lOptions)));
  678.     }
  679.  
  680. CdbDatabase            CdbDBEngine::OpenDatabase(
  681.     LPCTSTR        pstrName,
  682.     BOOL        bExclusive,         // = FALSE
  683.     BOOL        bReadOnly,            // = FALSE
  684.     LPCTSTR        pstrConnect)        // = NULL
  685.     {
  686.     DAODBEngine    *    peng    = (DAODBEngine *)GetInterface();
  687.     DAODatabase *    pdb        = NULL;
  688.  
  689.     if (!peng)
  690.         return FALSE;
  691.  
  692.     DAOMFC_CALL(peng->OpenDatabase(STB(pstrName), BTV(bExclusive), BTV(bReadOnly), STV(pstrConnect), &pdb));
  693.  
  694.     return pdb;
  695.     }
  696.  
  697.  
  698.  
  699. /*****************************************************************************
  700. * CdbError
  701. */
  702. // Administration
  703. CONSTRUCTOR            CdbError::CdbError(
  704.     VOID)
  705.     {
  706.     }
  707.  
  708. CONSTRUCTOR            CdbError::CdbError(
  709.     DAOError *    perr,
  710.     BOOL        bAddRef)    // = FALSE
  711.     {
  712.     CdbOleObject::SetInterface((LPUNKNOWN)perr, bAddRef);
  713.     }
  714.  
  715. CONSTRUCTOR            CdbError::CdbError(
  716.     const CdbError &o)
  717.     {
  718.     SetInterface(o.GetInterface(TRUE));
  719.     }
  720.  
  721. CdbError &            CdbError::operator =(
  722.     const CdbError &o)
  723.     {
  724.     SetInterface(o.GetInterface(TRUE));
  725.     return *this;
  726.     }
  727.  
  728. VOID                CdbError::OnInterfaceChange(
  729.     VOID)
  730.     {
  731.     }
  732.  
  733. // Properties
  734. LONG                CdbError::GetNumber(
  735.     VOID)
  736.     {
  737.     LPROPGET(DAOError, get_Number);
  738.     }
  739.  
  740. CString                CdbError::GetSource(
  741.     VOID)
  742.     {
  743.     SPROPGET(DAOError, get_Source);
  744.     }
  745.  
  746. CString                CdbError::GetDescription(
  747.     VOID)
  748.     {
  749.     SPROPGET(DAOError, get_Description);
  750.     }
  751.  
  752. CString                CdbError::GetHelpFile(
  753.     VOID)
  754.     {
  755.     SPROPGET(DAOError, get_HelpFile);
  756.     }
  757.  
  758. LONG                CdbError::GetHelpContext(
  759.     VOID)
  760.     {
  761.     LPROPGET(DAOError, get_HelpContext);
  762.     }
  763.  
  764. /*****************************************************************************
  765. * CdbWorkspace
  766. */
  767. // Administration
  768. CONSTRUCTOR            CdbWorkspace::CdbWorkspace(
  769.     VOID)
  770.     {
  771.     }
  772.  
  773. CONSTRUCTOR            CdbWorkspace::CdbWorkspace(
  774.     DAOWorkspace *    pwrk,
  775.     BOOL            bAddRef)    // = FALSE
  776.     {
  777.     CdbOleObject::SetInterface((LPUNKNOWN)pwrk, bAddRef);
  778.     }
  779.  
  780. CONSTRUCTOR            CdbWorkspace::CdbWorkspace(
  781.     const CdbWorkspace &o)
  782.     {
  783.     CdbOleObject::SetInterface(o.GetInterface(TRUE));
  784.     }
  785.  
  786. CdbWorkspace &        CdbWorkspace::operator =(
  787.     const CdbWorkspace &o)
  788.     {
  789.     CdbOleObject::SetInterface(o.GetInterface(TRUE));
  790.     return *this;
  791.     }
  792.  
  793. VOID                CdbWorkspace::OnInterfaceChange(
  794.     VOID)
  795.     {
  796.     DAOWorkspace *        pwrk     = (DAOWorkspace *)GetInterface();
  797.     DAOProperties *        pprps    = NULL;
  798.     DAOUsers *            pusrs    = NULL;
  799.     DAOGroups *            pgrps    = NULL;
  800.     DAODatabases *        pdbs    = NULL;
  801.  
  802.     if (pwrk)
  803.         {
  804.         pwrk->get_Properties(&pprps);
  805.         pwrk->get_Databases(&pdbs);
  806.         pwrk->get_Users(&pusrs);
  807.         pwrk->get_Groups(&pgrps);
  808.         }
  809.  
  810.     Properties.SetInterface(pprps);
  811.     Databases.SetInterface(pdbs);
  812.     Users.SetInterface(pusrs);
  813.     Groups.SetInterface(pgrps);
  814.     }
  815.  
  816. // Properties
  817. CString                CdbWorkspace::GetName(
  818.     VOID)
  819.     {
  820.     SPROPGET(DAOWorkspace, get_Name);
  821.     }
  822.  
  823. VOID                CdbWorkspace::SetName(
  824.     LPCTSTR pstr)
  825.     {
  826.     SPROPSET(DAOWorkspace, put_Name, pstr);
  827.     }
  828.  
  829. CString                CdbWorkspace::GetUserName(
  830.     VOID)
  831.     {
  832.     SPROPGET(DAOWorkspace, get_UserName);
  833.     }
  834.  
  835. BOOL                CdbWorkspace::GetIsolateODBCTrans(
  836.     VOID)
  837.     {
  838.     BPROPGET(DAOWorkspace, get_IsolateODBCTrans);
  839.     }
  840.  
  841. VOID                CdbWorkspace::SetIsolateODBCTrans(
  842.     BOOL b)
  843.     {
  844.     BPROPSET(DAOWorkspace, put_IsolateODBCTrans, b);
  845.     }
  846.  
  847. // Methods
  848. VOID                CdbWorkspace::BeginTrans(
  849.     VOID)
  850.     {
  851.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  852.  
  853.     DAOMFC_CALL(pwrk->BeginTrans());
  854.     }
  855.  
  856. VOID                CdbWorkspace::CommitTrans(
  857.     VOID)
  858.     {
  859.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  860.  
  861.     DAOMFC_CALL(pwrk->CommitTrans());
  862.     }
  863.  
  864. VOID                CdbWorkspace::Close(
  865.     VOID)
  866.     {
  867.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  868.  
  869.     DAOMFC_CALL(pwrk->Close());
  870.     }
  871.  
  872. VOID                CdbWorkspace::Rollback(
  873.     VOID)
  874.     {
  875.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  876.  
  877.     DAOMFC_CALL(pwrk->Rollback());
  878.     }
  879.  
  880. CdbDatabase            CdbWorkspace::OpenDatabase(
  881.     LPCTSTR    pstrName,
  882.     BOOL    bExclusive,        // = FALSE
  883.     BOOL    bReadOnly,        // = FALSE
  884.     LPCTSTR    pstrConnect)    // = NULL
  885.     {
  886.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  887.     DAODatabase *        pdb        = NULL;
  888.  
  889.     if (!pwrk)
  890.         return (DAODatabase *)NULL;
  891.  
  892.     DAOMFC_CALL(pwrk->OpenDatabase(STB(pstrName), BTV(bExclusive), BTV(bReadOnly), STV(pstrConnect), &pdb));
  893.  
  894.     return pdb;
  895.     }
  896.  
  897. CdbDatabase            CdbWorkspace::CreateDatabase(
  898.     LPCTSTR    pstrName,
  899.     LPCTSTR    pstrConnect,
  900.     LONG    lOption)    // = -1
  901.     {
  902.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  903.     DAODatabase *        pdb        = NULL;
  904.  
  905.     if (!pwrk)
  906.         return (DAODatabase *)NULL;
  907.  
  908.     DAOMFC_CALL(pwrk->CreateDatabase(STB(pstrName), STB(pstrConnect), OLTV(lOption), &pdb));
  909.  
  910.     return pdb;
  911.     }
  912.  
  913. CdbUser                CdbWorkspace::CreateUser(
  914.     LPCTSTR pstrName,        // = NULL
  915.     LPCTSTR pstrPID,        // = NULL
  916.     LPCTSTR pstrPassword)    // = NULL
  917.     {
  918.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  919.     DAOUser *            pusr    = NULL;
  920.  
  921.     if (!pwrk)
  922.         return (DAOUser *)NULL;
  923.  
  924.     DAOMFC_CALL(pwrk->CreateUser(STV(pstrName), STV(pstrPID), STV(pstrPassword), &pusr));
  925.  
  926.     return pusr;
  927.     }
  928.  
  929. CdbGroup            CdbWorkspace::CreateGroup(
  930.     LPCTSTR pstrName,    // = NULL
  931.     LPCTSTR pstrPID)    // = NULL
  932.     {
  933.     DAOWorkspace *        pwrk    = (DAOWorkspace *)GetInterface();
  934.     DAOGroup *            pgrp    = NULL;
  935.  
  936.     if (!pwrk)
  937.         return (DAOGroup *)NULL;
  938.  
  939.     DAOMFC_CALL(pwrk->CreateGroup(STV(pstrName), STV(pstrPID), &pgrp));
  940.  
  941.     return pgrp;
  942.     }
  943.  
  944. /*****************************************************************************
  945. * CdbDatabase
  946. */
  947. // Administration
  948. CONSTRUCTOR            CdbDatabase::CdbDatabase(
  949.     VOID)
  950.     {
  951.     }
  952.  
  953. CONSTRUCTOR            CdbDatabase::CdbDatabase(
  954.     DAODatabase *    pdb,
  955.     BOOL            bAddRef)    // = FALSE
  956.     {
  957.     CdbOleObject::SetInterface((LPUNKNOWN)pdb, bAddRef);
  958.     }
  959.  
  960. CONSTRUCTOR            CdbDatabase::CdbDatabase(
  961.     const CdbDatabase &o)
  962.     {
  963.     SetInterface(o.GetInterface(TRUE));
  964.     }
  965.  
  966. CdbDatabase &        CdbDatabase::operator =(
  967.     const CdbDatabase &o)
  968.     {
  969.     SetInterface(o.GetInterface(TRUE));
  970.     return *this;
  971.     }
  972.  
  973. VOID                CdbDatabase::OnInterfaceChange(
  974.     VOID)
  975.     {
  976.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  977.     DAOProperties *    pprps    = NULL;
  978.     DAOTableDefs *    ptds    = NULL;
  979.     DAOQueryDefs *    pqds    = NULL;
  980.     DAORelations *    prls    = NULL;
  981.     DAOContainers *    pcts    = NULL;
  982.     DAORecordsets *    prss    = NULL;
  983.  
  984.     if (pdb)
  985.         {
  986.         pdb->get_Properties(&pprps);
  987.         pdb->get_TableDefs(&ptds);
  988.         pdb->get_QueryDefs(&pqds);
  989.         pdb->get_Relations(&prls);
  990.         pdb->get_Containers(&pcts);
  991.         pdb->get_Recordsets(&prss);
  992.         }
  993.  
  994.     Properties.SetInterface(pprps);
  995.     TableDefs.SetInterface(ptds);
  996.     QueryDefs.SetInterface(pqds);
  997.     Relations.SetInterface(prls);
  998.     Containers.SetInterface(pcts);
  999.     Recordsets.SetInterface(prss);
  1000.     }
  1001.  
  1002. // Properties
  1003. LONG                CdbDatabase::GetCollatingOrder(
  1004.     VOID)
  1005.     {
  1006.     LPROPGET(DAODatabase, get_CollatingOrder);
  1007.     }
  1008.  
  1009. CString                CdbDatabase::GetConnect(
  1010.     VOID)
  1011.     {
  1012.     SPROPGET(DAODatabase, get_Connect);
  1013.     }
  1014.  
  1015. CString                CdbDatabase::GetName(
  1016.     VOID)
  1017.     {
  1018.     SPROPGET(DAODatabase, get_Name);
  1019.     }
  1020.  
  1021. SHORT                CdbDatabase::GetQueryTimeout(
  1022.     VOID)
  1023.     {
  1024.     WPROPGET(DAODatabase, get_QueryTimeout);
  1025.     }
  1026.  
  1027. VOID                CdbDatabase::SetQueryTimeout(
  1028.     SHORT s)
  1029.     {
  1030.     WPROPSET(DAODatabase, put_QueryTimeout, s);
  1031.     }
  1032.  
  1033. BOOL                CdbDatabase::GetTransactions(
  1034.     VOID)
  1035.     {
  1036.     BPROPGET(DAODatabase, get_Transactions);
  1037.     }
  1038.  
  1039. BOOL                CdbDatabase::GetUpdatable(
  1040.     VOID)
  1041.     {
  1042.     BPROPGET(DAODatabase, get_Updatable);
  1043.     }
  1044.  
  1045. CString                CdbDatabase::GetVersion(
  1046.     VOID)
  1047.     {
  1048.     SPROPGET(DAODatabase, get_Version);
  1049.     }
  1050.  
  1051. LONG                CdbDatabase::GetRecordsAffected(
  1052.     VOID)
  1053.     {
  1054.     LPROPGET(DAODatabase, get_RecordsAffected);
  1055.     }
  1056.  
  1057. // Methods
  1058. VOID                CdbDatabase::Close(
  1059.     VOID)
  1060.     {
  1061.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1062.  
  1063.     DAOMFC_CALL(pdb->Close());
  1064.     }
  1065.  
  1066. VOID                CdbDatabase::Execute(
  1067.     LPCTSTR    pstrQuery,
  1068.     LONG    lOption)    // = -1
  1069.     {
  1070.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1071.  
  1072.     DAOMFC_CALL(pdb->Execute(STB(pstrQuery), OLTV(lOption)));
  1073.     }
  1074.  
  1075. CdbRecordset        CdbDatabase::OpenRecordset(
  1076.     LPCTSTR    pstrName,
  1077.     LONG    lType,        // = -1
  1078.     LONG    lOptions)    // = -1
  1079.     {
  1080.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1081.     DAORecordset *    prs        = NULL;
  1082.  
  1083.     if (!pdb)
  1084.         return (DAORecordset *)NULL;
  1085.  
  1086.     DAOMFC_CALL(pdb->OpenRecordset(STB(pstrName), OLTV(lType), OLTV(lOptions), &prs));
  1087.  
  1088.     return prs;
  1089.     }
  1090.  
  1091. CdbProperty            CdbDatabase::CreateProperty(
  1092.     LPCTSTR        pstrName,    // = NULL
  1093.     LONG        lType,        // = -1
  1094.     LPVARIANT    pvValue,    // = NULL
  1095.     BOOL        bDDL)        // = FALSE
  1096.     {
  1097.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1098.     DAOProperty *    pprp    = NULL;
  1099.  
  1100.     if (!pdb)
  1101.         return (DAOProperty *)NULL;
  1102.  
  1103.     DAOMFC_CALL(pdb->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
  1104.  
  1105.     return pprp;
  1106.     }
  1107.  
  1108. CdbRelation            CdbDatabase::CreateRelation(
  1109.     LPCTSTR    pstrName,        // = NULL
  1110.     LPCTSTR    pstrTable,        // = NULL
  1111.     LPCTSTR    pstrForiegn,    // = NULL
  1112.     LONG    lAttributes)    // = -1
  1113.     {
  1114.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1115.     DAORelation *    prl        = NULL;
  1116.  
  1117.     if (!pdb)
  1118.         return (DAORelation *)NULL;
  1119.  
  1120.     DAOMFC_CALL(pdb->CreateRelation(STV(pstrName), STV(pstrTable), STV(pstrForiegn), OLTV(lAttributes), &prl));
  1121.  
  1122.     return prl;
  1123.     }
  1124.  
  1125. CdbTableDef            CdbDatabase::CreateTableDef(
  1126.     LPCTSTR    pstrName,        // = NULL
  1127.     LONG    lAttributes,    // = -1
  1128.     LPCTSTR    pstrSource,        // = NULL
  1129.     LPCTSTR    pstrConnect)    // = NULL
  1130.     {
  1131.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1132.     DAOTableDef *    ptd        = NULL;
  1133.  
  1134.     if (!pdb)
  1135.         return (DAOTableDef *)NULL;
  1136.  
  1137.     DAOMFC_CALL(pdb->CreateTableDef(STV(pstrName), OLTV(lAttributes), STV(pstrSource), STV(pstrConnect), &ptd));
  1138.  
  1139.     return ptd;
  1140.     }
  1141.  
  1142. CdbQueryDef            CdbDatabase::CreateQueryDef(
  1143.     LPCTSTR pstrName,    // = NULL
  1144.     LPCTSTR pstrSQL)    // = NULL
  1145.     {
  1146.     DAODatabase *    pdb        = (DAODatabase *)GetInterface();
  1147.     DAOQueryDef *    pqd        = NULL;
  1148.  
  1149.     if (!pdb)
  1150.         return (DAOQueryDef *)NULL;
  1151.  
  1152.     DAOMFC_CALL(pdb->CreateQueryDef(STV(pstrName), STV(pstrSQL), &pqd));
  1153.  
  1154.     return pqd;
  1155.     }
  1156.  
  1157. /*****************************************************************************
  1158. * CdbRecordset
  1159. */
  1160. // Administration
  1161. CONSTRUCTOR            CdbRecordset::CdbRecordset(
  1162.     VOID)
  1163.     {
  1164.     }
  1165.  
  1166. CONSTRUCTOR            CdbRecordset::CdbRecordset(
  1167.     DAORecordset *    prs,
  1168.     BOOL             bAddRef)    // = FALSE
  1169.     {
  1170.     CdbOleObject::SetInterface((LPUNKNOWN)prs, bAddRef);
  1171.     }
  1172.  
  1173. CONSTRUCTOR            CdbRecordset::CdbRecordset(
  1174.     const CdbRecordset &o)
  1175.     {
  1176.     SetInterface(o.GetInterface(TRUE));
  1177.     }
  1178.  
  1179. CdbRecordset &        CdbRecordset::operator =(
  1180.     const CdbRecordset &o)
  1181.     {
  1182.     SetInterface(o.GetInterface(TRUE));
  1183.     return *this;
  1184.     }
  1185.  
  1186. VOID                CdbRecordset::OnInterfaceChange(
  1187.     VOID)
  1188.     {
  1189.     DAORecordset *        prs        = (DAORecordset *)GetInterface();
  1190.     DAOProperties *        pprps    = NULL;
  1191.     DAOFields *            pflds    = NULL;
  1192.     if (prs)
  1193.         {
  1194.         prs->get_Properties(&pprps);
  1195.         prs->get_Fields(&pflds);
  1196.         }
  1197.  
  1198.     Properties.SetInterface(pprps);
  1199.     Fields.SetInterface(pflds);
  1200.     }
  1201.  
  1202. VOID                CdbRecordset::SetGetRowsExInt(
  1203.     VOID)
  1204.     {
  1205.     DAORecordset *        prs        = (DAORecordset *)GetInterface();
  1206.     ICDAORecordset *    pGetRows = NULL;
  1207.     if (prs)
  1208.         {
  1209.         prs->QueryInterface(IID_ICDAORecordset, (void **)&pGetRows);
  1210.         }
  1211.     m_GetRowsInt.SetInterface(pGetRows);
  1212.     }
  1213.  
  1214. // Properties
  1215. BOOL                CdbRecordset::GetBOF(
  1216.     VOID)
  1217.     {
  1218.     BPROPGET(DAORecordset, get_BOF);
  1219.     }
  1220.  
  1221. CdbBookmark            CdbRecordset::GetBookmark(
  1222.     VOID)
  1223.     {
  1224.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1225.     LPSAFEARRAY        psa = NULL;
  1226.  
  1227.     if (!prs)
  1228.         return (LPSAFEARRAY)NULL;
  1229.  
  1230.     DAOMFC_CALL(prs->get_Bookmark(&psa));
  1231.  
  1232.     return psa;
  1233.     }
  1234.  
  1235. VOID                CdbRecordset::SetBookmark(
  1236.     class CdbBookmark & bm)
  1237.     {
  1238.     LPSAFEARRAY        psa = (LPSAFEARRAY)bm;
  1239.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1240.  
  1241.     DAOMFC_CALL(prs->put_Bookmark(&psa));
  1242.     }
  1243.  
  1244. BOOL                CdbRecordset::GetBookmarkable(
  1245.     VOID)
  1246.     {
  1247.     BPROPGET(DAORecordset, get_Bookmarkable);
  1248.     }
  1249.  
  1250. COleDateTime            CdbRecordset::GetDateCreated(
  1251.     VOID)
  1252.     {
  1253.     DPROPGET(DAORecordset, get_DateCreated);
  1254.     }
  1255.  
  1256. COleDateTime            CdbRecordset::GetLastUpdated(
  1257.     VOID)
  1258.     {
  1259.     DPROPGET(DAORecordset, get_LastUpdated);
  1260.     }
  1261.  
  1262. BOOL                CdbRecordset::GetEOF(
  1263.     VOID)
  1264.     {
  1265.     BPROPGET(DAORecordset, get_EOF);
  1266.     }
  1267.  
  1268. CString                CdbRecordset::GetFilter(
  1269.     VOID)
  1270.     {
  1271.     SPROPGET(DAORecordset, get_Filter);
  1272.     }
  1273.  
  1274. VOID                CdbRecordset::SetFilter(
  1275.     LPCTSTR pstr)
  1276.     {
  1277.     SPROPSET(DAORecordset, put_Filter, pstr);
  1278.     }
  1279.  
  1280. CString                CdbRecordset::GetIndex(
  1281.     VOID)
  1282.     {
  1283.     SPROPGET(DAORecordset, get_Index);
  1284.     }
  1285.  
  1286. VOID                CdbRecordset::SetIndex(
  1287.     LPCTSTR pstr)
  1288.     {
  1289.     SPROPSET(DAORecordset, put_Index, pstr);
  1290.     }
  1291.  
  1292. CdbBookmark            CdbRecordset::GetLastModified(
  1293.     VOID)
  1294.     {
  1295.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1296.     LPSAFEARRAY        psa;
  1297.  
  1298.     if (!prs)
  1299.         return (LPSAFEARRAY)NULL;
  1300.  
  1301.     DAOMFC_CALL(prs->get_LastModified(&psa));
  1302.  
  1303.     return psa;
  1304.     }
  1305.  
  1306. BOOL                CdbRecordset::GetLockEdits(
  1307.     VOID)
  1308.     {
  1309.     BPROPGET(DAORecordset, get_LockEdits);
  1310.     }
  1311.  
  1312. VOID                CdbRecordset::SetLockEdits(
  1313.     BOOL b)
  1314.     {
  1315.     BPROPSET(DAORecordset, put_LockEdits, b);
  1316.     }
  1317.  
  1318. CString                CdbRecordset::GetName(
  1319.     VOID)
  1320.     {
  1321.     SPROPGET(DAORecordset, get_Name);
  1322.     }
  1323.  
  1324. BOOL                CdbRecordset::GetNoMatch(
  1325.     VOID)
  1326.     {
  1327.     BPROPGET(DAORecordset, get_NoMatch);
  1328.     }
  1329.  
  1330. CString                CdbRecordset::GetSort(
  1331.     VOID)
  1332.     {
  1333.     SPROPGET(DAORecordset, get_Sort);
  1334.     }
  1335.  
  1336. VOID                CdbRecordset::SetSort(
  1337.     LPCTSTR pstr)
  1338.     {
  1339.     SPROPSET(DAORecordset, put_Sort, pstr);
  1340.     }
  1341.  
  1342. BOOL                CdbRecordset::GetTransactions(
  1343.     VOID)
  1344.     {
  1345.     BPROPGET(DAORecordset, get_Transactions);
  1346.     }
  1347.  
  1348. SHORT                CdbRecordset::GetType(
  1349.     VOID)
  1350.     {
  1351.     WPROPGET(DAORecordset, get_Type);
  1352.     }
  1353.  
  1354. LONG                CdbRecordset::GetRecordCount(
  1355.     VOID)
  1356.     {
  1357.     LPROPGET(DAORecordset, get_RecordCount);
  1358.     }
  1359.  
  1360. BOOL                CdbRecordset::GetUpdatable(
  1361.     VOID)
  1362.     {
  1363.     BPROPGET(DAORecordset, get_Updatable);
  1364.     }
  1365.  
  1366. BOOL                CdbRecordset::GetRestartable(
  1367.     VOID)
  1368.     {
  1369.     BPROPGET(DAORecordset, get_Restartable);
  1370.     }
  1371.  
  1372. CString                CdbRecordset::GetValidationText(
  1373.     VOID)
  1374.     {
  1375.     SPROPGET(DAORecordset, get_ValidationText);
  1376.     }
  1377.  
  1378. CString                CdbRecordset::GetValidationRule(
  1379.     VOID)
  1380.     {
  1381.     SPROPGET(DAORecordset, get_ValidationRule);
  1382.     }
  1383.  
  1384. CdbBookmark            CdbRecordset::GetCacheStart(
  1385.     VOID)
  1386.     {
  1387.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1388.     LPSAFEARRAY        psa;
  1389.  
  1390.     if (!prs)
  1391.         return (LPSAFEARRAY)NULL;
  1392.  
  1393.     DAOMFC_CALL(prs->get_CacheStart(&psa));
  1394.  
  1395.     return psa;
  1396.     }
  1397.  
  1398. VOID                CdbRecordset::SetCacheStart(
  1399.     CdbBookmark &bm)
  1400.     {
  1401.     LPSAFEARRAY        psa = (LPSAFEARRAY)bm;
  1402.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1403.  
  1404.     DAOMFC_CALL(prs->put_CacheStart(&psa));
  1405.     }
  1406.  
  1407. LONG                CdbRecordset::GetCacheSize(
  1408.     VOID)
  1409.     {
  1410.     LPROPGET(DAORecordset, get_CacheSize);
  1411.     }
  1412.  
  1413. VOID                CdbRecordset::SetCacheSize(
  1414.     LONG l)
  1415.     {
  1416.     LPROPSET(DAORecordset, put_CacheSize, l);
  1417.     }
  1418.  
  1419. FLOAT                CdbRecordset::GetPercentPosition(
  1420.     VOID)
  1421.     {
  1422.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1423.     FLOAT            f    = (FLOAT)0.0;
  1424.  
  1425.     if (!prs)
  1426.         return (FLOAT)0.0;
  1427.  
  1428.     DAOMFC_CALL(prs->get_PercentPosition(&f));
  1429.  
  1430.     return f;
  1431.     }
  1432.  
  1433. VOID                CdbRecordset::SetPercentPosition(
  1434.     FLOAT f)
  1435.     {
  1436.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1437.  
  1438.     DAOMFC_CALL(prs->put_PercentPosition(f));
  1439.     }
  1440.  
  1441. LONG                CdbRecordset::GetAbsolutePosition(
  1442.     VOID)
  1443.     {
  1444.     LPROPGET(DAORecordset, get_AbsolutePosition);
  1445.     }
  1446.  
  1447. VOID                CdbRecordset::SetAbsolutePosition(
  1448.     LONG l)
  1449.     {
  1450.     LPROPSET(DAORecordset, put_AbsolutePosition, l);
  1451.     }
  1452.  
  1453. SHORT                CdbRecordset::GetEditMode(
  1454.     VOID)
  1455.     {
  1456.     WPROPGET(DAORecordset, get_EditMode);
  1457.     }
  1458.  
  1459. // Methods
  1460. VOID                CdbRecordset::CancelUpdate(
  1461.     VOID)
  1462.     {
  1463.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1464.  
  1465.     DAOMFC_CALL(prs->CancelUpdate());
  1466.     }
  1467.  
  1468. VOID                CdbRecordset::AddNew(
  1469.     VOID)
  1470.     {
  1471.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1472.  
  1473.     DAOMFC_CALL(prs->AddNew());
  1474.     }
  1475.  
  1476. VOID                CdbRecordset::Close(
  1477.     VOID)
  1478.     {
  1479.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1480.  
  1481.     DAOMFC_CALL(prs->Close());
  1482.     }
  1483.  
  1484. CdbRecordset        CdbRecordset::OpenRecordset(
  1485.     LONG    lType,        // = -1
  1486.     LONG     lOption)    // = -1
  1487.     {
  1488.     DAORecordset *    prs        = (DAORecordset *)GetInterface();
  1489.     DAORecordset *    prsNew    = NULL;
  1490.  
  1491.     if (!prs)
  1492.         return (DAORecordset *)NULL;
  1493.  
  1494.     DAOMFC_CALL(prs->OpenRecordset(SHTV(lType), OLTV(lOption), &prsNew));
  1495.  
  1496.     return prsNew;
  1497.     }
  1498.  
  1499. VOID                CdbRecordset::Delete(
  1500.     VOID)
  1501.     {
  1502.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1503.  
  1504.     DAOMFC_CALL(prs->Delete());
  1505.     }
  1506.  
  1507. VOID                CdbRecordset::Edit(
  1508.     VOID)
  1509.     {
  1510.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1511.  
  1512.     DAOMFC_CALL(prs->Edit());
  1513.     }
  1514.  
  1515. VOID                CdbRecordset::FindFirst(
  1516.     LPCTSTR pstrCriteria)
  1517.     {
  1518.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1519.  
  1520.     DAOMFC_CALL(prs->FindFirst(STB(pstrCriteria)));
  1521.     }
  1522.  
  1523. VOID                CdbRecordset::FindLast(
  1524.     LPCTSTR pstrCriteria)
  1525.     {
  1526.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1527.  
  1528.     DAOMFC_CALL(prs->FindLast(STB(pstrCriteria)));
  1529.     }
  1530.  
  1531. VOID                CdbRecordset::FindNext(
  1532.     LPCTSTR pstrCriteria)
  1533.     {
  1534.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1535.  
  1536.     DAOMFC_CALL(prs->FindNext(STB(pstrCriteria)));
  1537.     }
  1538.  
  1539. VOID                CdbRecordset::FindPrevious(
  1540.     LPCTSTR pstrCriteria)
  1541.     {
  1542.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1543.  
  1544.     DAOMFC_CALL(prs->FindPrevious(STB(pstrCriteria)));
  1545.     }
  1546.  
  1547. VOID                CdbRecordset::MoveFirst(
  1548.     VOID)
  1549.     {
  1550.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1551.  
  1552.     DAOMFC_CALL(prs->MoveFirst());
  1553.     }
  1554.  
  1555. VOID                CdbRecordset::MoveLast(
  1556.     VOID)
  1557.     {
  1558.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1559.  
  1560.     DAOMFC_CALL(prs->MoveLast());
  1561.     }
  1562.  
  1563. VOID                CdbRecordset::MoveNext(
  1564.     VOID)
  1565.     {
  1566.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1567.  
  1568.     DAOMFC_CALL(prs->MoveNext());
  1569.     }
  1570.  
  1571. VOID                CdbRecordset::MovePrevious(
  1572.     VOID)
  1573.     {
  1574.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1575.  
  1576.     DAOMFC_CALL(prs->MovePrevious());
  1577.     }
  1578.  
  1579.  
  1580. VOID                CdbRecordset::Seek(
  1581.     LPCTSTR    pstrComparison,
  1582.     LONG lNumFields,
  1583.     COleVariant    cKey,
  1584.     ...)
  1585.     {
  1586.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1587.     COleVariant *    lpV;
  1588.     va_list            valist;
  1589.     CdbVariant        v[13];
  1590.     LONG            lIndex;
  1591.  
  1592.     ASSERT(lNumFields <= DAO_MAXSEEKFIELDS && lNumFields > 0);
  1593.  
  1594.     lpV = &cKey;
  1595.     va_start(valist, cKey);
  1596.  
  1597.     v[0] = *lpV;
  1598.     for(lIndex = 1; lIndex < lNumFields && (lpV = &(va_arg(valist, COleVariant))) != 0; lIndex++ )
  1599.         {
  1600.         v[lIndex] = *lpV;
  1601.         }
  1602.  
  1603.     va_end(valist);
  1604.  
  1605.     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]));
  1606.     }
  1607.  
  1608. VOID                CdbRecordset::Update(
  1609.     VOID)
  1610.     {
  1611.     DAORecordset *    prs = (DAORecordset *)GetInterface();
  1612.  
  1613.     DAOMFC_CALL(prs->Update());
  1614.     }
  1615.  
  1616. CdbRecordset        CdbRecordset::Clone(
  1617.     VOID)
  1618.     {
  1619.     DAORecordset *    prs     = (DAORecordset *)GetInterface();
  1620.     DAORecordset *    prsNew    = NULL;
  1621.  
  1622.     if (!prs)
  1623.         return FALSE;
  1624.  
  1625.     DAOMFC_CALL(prs->Clone(&prsNew));
  1626.  
  1627.     return prsNew;
  1628.     }
  1629.  
  1630. VOID                CdbRecordset::Requery(
  1631.     CdbQueryDef *pq)    // = NULL
  1632.     {
  1633.     DAORecordset *    prs     = (DAORecordset *)GetInterface();
  1634.     COleVariant        Var;
  1635.  
  1636.     //Manually load the Query Def as a dispatch
  1637.     if (!pq)
  1638.         {
  1639.         Var.vt            = VT_ERROR;
  1640.         Var.scode        = DISP_E_PARAMNOTFOUND;
  1641.         }
  1642.     else
  1643.         {
  1644.         Var.vt            = VT_DISPATCH;
  1645.         Var.pdispVal    = (LPDISPATCH)pq->GetInterface();
  1646.         }
  1647.  
  1648.     DAOMFC_CALL(prs->Requery(Var));
  1649.     }
  1650.  
  1651. VOID                CdbRecordset::Move(
  1652.     LONG             lRows,
  1653.     CdbBookmark     *pbm)    // = NULL
  1654.     {
  1655.     LPSAFEARRAY        psa = NULL;
  1656.     COleVariant        Var;
  1657.  
  1658.     if(pbm)
  1659.         {
  1660.         psa = (LPSAFEARRAY)(*pbm);
  1661.         }
  1662.  
  1663.     DAORecordset *    prs     = (DAORecordset *)GetInterface();
  1664.  
  1665.     //Load the safe array into the COleVariant
  1666.     ATV(psa, Var);
  1667.  
  1668.     DAOMFC_CALL(prs->Move(lRows, Var));
  1669.     }
  1670.  
  1671. VOID                CdbRecordset::FillCache(
  1672.     LONG             lRows,    // = -1
  1673.     CdbBookmark *    pbm)    // = NULL
  1674.     {
  1675.     DAORecordset *    prs     = (DAORecordset *)GetInterface();
  1676.     COleVariant        Var;
  1677.  
  1678.     //Load the safe array into the COleVariant
  1679.     ATV((LPSAFEARRAY)pbm, Var);
  1680.  
  1681.     DAOMFC_CALL(prs->FillCache(OLTV(lRows), Var));
  1682.     }
  1683.  
  1684. CdbQueryDef            CdbRecordset::CopyQueryDef(
  1685.     VOID)
  1686.     {
  1687.     DAORecordset *    prs     = (DAORecordset *)GetInterface();
  1688.     DAOQueryDef *    pqd        = NULL;
  1689.  
  1690.     if (!prs)
  1691.         return (DAOQueryDef *)NULL;
  1692.  
  1693.     DAOMFC_CALL(prs->CopyQueryDef(&pqd));
  1694.  
  1695.     return pqd;
  1696.     }
  1697.  
  1698. COleVariant            CdbRecordset::GetRows(
  1699.     LONG lRows)        // = -1
  1700.     {
  1701.     DAORecordset *    prs     = (DAORecordset *)GetInterface();
  1702.     VARIANT            v;
  1703.  
  1704.     if (!prs)
  1705.         return (LPVARIANT)NULL;
  1706.  
  1707.     VariantInit(&v);
  1708.     DAOMFC_CALL(prs->GetRows(OLTV(lRows), &v));
  1709.  
  1710.     return &v;
  1711.     }
  1712.  
  1713. LONG                CdbRecordset::GetRowsEx(
  1714.     LPVOID                pvBuffer,
  1715.     LONG                cbRow,
  1716.     LPDAORSETBINDING     prb,
  1717.     LONG                 cBinding,
  1718.     LPVOID                pvVarBuffer, //= NULL
  1719.     LONG                cbVarBuffer, // = 0
  1720.     LONG                lRows)        // = -1
  1721.     {
  1722.     ICDAORecordset *    prs;
  1723.     DAOFETCHROWS        fetch;
  1724.     HRESULT                hresult;
  1725.     
  1726.     ASSERT(cBinding > 0);
  1727.     ASSERT(prb != 0);
  1728.  
  1729.     //Clear flags
  1730.     fetch.dwFlags = 0;
  1731.  
  1732.     //The GetRowsEx interface isn't set until the first time this function
  1733.     //is called
  1734.     if(!m_GetRowsInt.Exists())
  1735.         SetGetRowsExInt();
  1736.  
  1737.     prs    = (ICDAORecordset *)m_GetRowsInt.GetInterface();
  1738.  
  1739.     if (!prs)
  1740.         return 0L;
  1741.  
  1742.     LPDAOCOLUMNBINDING     pColumnBind = new DAOCOLUMNBINDING [cBinding];
  1743.  
  1744.     for(LONG iBinding=0;iBinding<cBinding;iBinding++)
  1745.         {
  1746.         if(prb[iBinding].dwBindIndexType == dbBindIndexINT)
  1747.             {
  1748.             pColumnBind[iBinding].columnID.dwKind = DAOCOLKIND_IND;
  1749.             pColumnBind[iBinding].columnID.ind = prb[iBinding].i;
  1750.             }
  1751.         else
  1752.             {
  1753. #ifdef _UNICODE
  1754.             pColumnBind[iBinding].columnID.dwKind = DAOCOLKIND_WSTR;
  1755.             pColumnBind[iBinding].columnID.lpwstr = prb[iBinding].pstr;
  1756. #else
  1757.             pColumnBind[iBinding].columnID.dwKind = DAOCOLKIND_STR;
  1758.             pColumnBind[iBinding].columnID.lpstr = prb[iBinding].pstr;
  1759. #endif
  1760.  
  1761.             }
  1762.         pColumnBind[iBinding].cbDataOffset    = prb[iBinding].dwOffset;
  1763.         pColumnBind[iBinding].cbMaxLen        = prb[iBinding].cb;
  1764.         pColumnBind[iBinding].cbInfoOffset    = DAO_NOINDICATOR;
  1765.         
  1766.         //Variants bound differently
  1767.         if(prb[iBinding].dwType != dbBindVARIANT)
  1768.             {
  1769.             pColumnBind[iBinding].dwBinding        = DAOBINDING_DIRECT;
  1770.             }
  1771.         else
  1772.             {
  1773.             pColumnBind[iBinding].dwBinding        = DAOBINDING_VARIANT;
  1774.             }
  1775.         pColumnBind[iBinding].dwDataType    = prb[iBinding].dwType;
  1776.         pColumnBind[iBinding].dwUser        = 0;        }
  1777.  
  1778.     fetch.cRowsRequested = lRows;
  1779.     fetch.pData = pvBuffer;
  1780.     fetch.pVarData = pvVarBuffer;
  1781.     fetch.cbVarData = cbVarBuffer;
  1782.  
  1783.     hresult = prs->GetRows(0, cBinding, (LPDAOCOLUMNBINDING)&pColumnBind[0], cbRow, (LPDAOFETCHROWS)&fetch);
  1784.  
  1785.     delete [] pColumnBind;
  1786.  
  1787. /*    There are error text strings in DBDAOx(u).dll in a string table for GetRowsEx
  1788.     which are currently disabled. They will show up alongside the published DAO
  1789.     errors in a later release
  1790.  
  1791.     //Check return code
  1792. #if !defined(DAOMFC_DONT_THROW_EXCEPTIONS)
  1793.     LONG    lstrID;
  1794.     switch (GetScode(hresult))
  1795.         {
  1796.         case S_BUFFERTOOSMALL :
  1797.             lstrID = IDS_BUFFERTOOSMALL;
  1798.             break;
  1799.  
  1800.         case S_ENDOFCURSOR:
  1801.             lstrID = IDS_ENDOFCURSOR;
  1802.             break;
  1803.  
  1804.         case S_SILENTCANCEL:
  1805.             lstrID = IDS_SILENTCANCEL;
  1806.             break;
  1807.  
  1808.         case S_RECORDDELETED:
  1809.             lstrID = IDS_RECORDDELETED;
  1810.             break;
  1811.  
  1812.         case E_ROWTOOSHORT:
  1813.             lstrID = IDS_ROWTOOSHORT;
  1814.             break;
  1815.  
  1816.         case E_BADBINDINFO:
  1817.             lstrID = IDS_BADBINDINFO;
  1818.             break;
  1819.  
  1820.         case E_COLUMNUNAVAILABLE:
  1821.             lstrID = IDS_COLUMNUNAVAILABLE;
  1822.             break;
  1823.             
  1824.         default:            
  1825.             lstrID = 0L;
  1826.             }
  1827.  
  1828.     if(lstrID)
  1829.         {
  1830.         CString strErr;
  1831.         BSTR bstrVal;
  1832.         strErr.LoadString(lstrID);
  1833. #ifdef UNICODE
  1834.         bstrVal = SysAllocString(strErr);
  1835. #else
  1836.         bstrVal = SysAllocStringByteLen(strErr, strlen(strErr));
  1837. #endif
  1838.         SetRichErrorInfo(L"DBDAO", bstrVal, NULL, 0L);
  1839.  
  1840.         SysFreeString(bstrVal);
  1841.         }
  1842. */
  1843. #if !defined(DAOMFC_DONT_THROW_EXCEPTIONS)
  1844.     if(FAILED(hresult)) 
  1845.         {
  1846.         TRACE0("\nGetRowsEX Call Failed.\n\t"); 
  1847.         TRACE2("\nIn file %s on line %d\n", THIS_FILE, __LINE__);
  1848.         TRACE1("hResult = %X\n", hresult);
  1849.         if (GetScode(hresult) == E_OUTOFMEMORY)
  1850.             {
  1851.             AfxThrowMemoryException();
  1852.             }
  1853.         else
  1854.             {
  1855.             throw CdbException(hresult);
  1856.             }
  1857.     
  1858.         }
  1859. #endif
  1860.     return fetch.cRowsReturned;
  1861.     }
  1862.  
  1863. COleVariant            CdbRecordset::GetField(
  1864.     LPCTSTR pstrIndex)
  1865.     {
  1866.     COleVariant vValue;
  1867.  
  1868.     GetFieldV(STV(pstrIndex), vValue);
  1869.       
  1870.     return vValue;
  1871.     }
  1872.  
  1873. COleVariant            CdbRecordset::GetField(
  1874.     LONG lIndex)
  1875.     {
  1876.     COleVariant vValue;
  1877.          
  1878.     GetFieldV(LTV(lIndex), vValue);
  1879.       
  1880.     return vValue;
  1881.     }
  1882.  
  1883.  
  1884. VOID            CdbRecordset::SetField(
  1885.     LPCTSTR pstrIndex,
  1886.     LPVARIANT pv)
  1887.     {
  1888.     SetFieldV(STV(pstrIndex), pv);
  1889.     }
  1890.  
  1891. VOID            CdbRecordset::SetField(
  1892.     LONG lIndex,
  1893.     LPVARIANT pv)
  1894.     {
  1895.     SetFieldV(LTV(lIndex), pv);
  1896.     }
  1897.  
  1898.  
  1899. /*****************************************************************************
  1900. * CdbGetRowsEx
  1901. */
  1902. // Administration
  1903. CONSTRUCTOR            CdbGetRowsEx::CdbGetRowsEx(
  1904.     VOID)
  1905.     {
  1906.     }
  1907.  
  1908. CONSTRUCTOR            CdbGetRowsEx::CdbGetRowsEx(
  1909.     ICDAORecordset *    pGetRows,
  1910.     BOOL         bAddRef)    // = FALSE
  1911.     {
  1912.     CdbOleObject::SetInterface((LPUNKNOWN)pGetRows, bAddRef);
  1913.     }
  1914.  
  1915. CONSTRUCTOR            CdbGetRowsEx::CdbGetRowsEx(
  1916.     const CdbGetRowsEx &o)
  1917.     {
  1918.     SetInterface(o.GetInterface(TRUE));
  1919.     }
  1920.  
  1921. CdbGetRowsEx &            CdbGetRowsEx::operator =(
  1922.     const CdbGetRowsEx &o)
  1923.     {
  1924.     SetInterface(o.GetInterface(TRUE));
  1925.     return *this;
  1926.     }
  1927.  
  1928.  
  1929. VOID            CdbGetRowsEx::OnInterfaceChange(
  1930.     VOID)
  1931.     {
  1932.     ICDAORecordset * pGetRows     = (ICDAORecordset *)GetInterface();
  1933.  
  1934.     }
  1935.  
  1936.  
  1937. /*****************************************************************************
  1938. * CdbField
  1939. */
  1940. // Administration
  1941. CONSTRUCTOR            CdbField::CdbField(
  1942.     VOID)
  1943.     {
  1944.     }
  1945.  
  1946. CONSTRUCTOR            CdbField::CdbField(
  1947.     DAOField *    pfld,
  1948.     BOOL         bAddRef)    // = FALSE
  1949.     {
  1950.     CdbOleObject::SetInterface((LPUNKNOWN)pfld, bAddRef);
  1951.     }
  1952.  
  1953. CONSTRUCTOR            CdbField::CdbField(
  1954.     const CdbField &o)
  1955.     {
  1956.     SetInterface(o.GetInterface(TRUE));
  1957.     }
  1958.  
  1959. CdbField &            CdbField::operator =(
  1960.     const CdbField &o)
  1961.     {
  1962.     SetInterface(o.GetInterface(TRUE));
  1963.     return *this;
  1964.     }
  1965.  
  1966. VOID                CdbField::OnInterfaceChange(
  1967.     VOID)
  1968.     {
  1969.     DAOField *        pfld    = (DAOField *)GetInterface();
  1970.     DAOProperties *    pprps    = NULL;
  1971.  
  1972.     if (pfld)
  1973.         {
  1974.         pfld->get_Properties(&pprps);
  1975.         }
  1976.  
  1977.     Properties.SetInterface(pprps);
  1978.     }
  1979.  
  1980. // Properties
  1981. LONG                CdbField::GetCollatingOrder(
  1982.     VOID)
  1983.     {
  1984.     LPROPGET(DAOField, get_CollatingOrder);
  1985.     }
  1986.  
  1987. SHORT                CdbField::GetType(
  1988.     VOID)
  1989.     {
  1990.     WPROPGET(DAOField, get_Type);
  1991.     }
  1992.  
  1993. VOID                CdbField::SetType(
  1994.     SHORT s)
  1995.     {
  1996.     WPROPSET(DAOField, put_Type, s);
  1997.     }
  1998.  
  1999. CString                CdbField::GetName(
  2000.     VOID)
  2001.     {
  2002.     SPROPGET(DAOField, get_Name);
  2003.     }
  2004.  
  2005. VOID                CdbField::SetName(
  2006.     LPCTSTR pstr)
  2007.     {
  2008.     SPROPSET(DAOField, put_Name, pstr);
  2009.     }
  2010.  
  2011. LONG                CdbField::GetSize(
  2012.     VOID)
  2013.     {
  2014.     LPROPGET(DAOField, get_Size);
  2015.     }
  2016.  
  2017. VOID                CdbField::SetSize(
  2018.     LONG l)
  2019.     {
  2020.     LPROPSET(DAOField, put_Size, l);
  2021.     }
  2022.  
  2023. CString                CdbField::GetSourceField(
  2024.     VOID)
  2025.     {
  2026.     SPROPGET(DAOField, get_SourceField);
  2027.     }
  2028.  
  2029. CString                CdbField::GetSourceTable(
  2030.     VOID)
  2031.     {
  2032.     SPROPGET(DAOField, get_SourceTable);
  2033.     }
  2034.  
  2035. COleVariant            CdbField::GetValue(
  2036.     VOID)
  2037.     {
  2038.     VPROPGET(DAOField, get_Value);
  2039.     }
  2040.  
  2041.  
  2042. VOID                CdbField::SetValue(
  2043.     LPVARIANT pv)
  2044.     {
  2045.     VPROPSET(DAOField, put_Value, pv);
  2046.     }
  2047.  
  2048. LONG                CdbField::GetAttributes(
  2049.     VOID)
  2050.     {
  2051.     LPROPGET(DAOField, get_Attributes);
  2052.     }
  2053.  
  2054. VOID                CdbField::SetAttributes(
  2055.     LONG l)
  2056.     {
  2057.     LPROPSET(DAOField, put_Attributes, l);
  2058.     }
  2059.  
  2060. SHORT                CdbField::GetOrdinalPosition(
  2061.     VOID)
  2062.     {
  2063.     WPROPGET(DAOField, get_OrdinalPosition);
  2064.     }
  2065.  
  2066. VOID                CdbField::SetOrdinalPosition(
  2067.     SHORT s)
  2068.     {
  2069.     WPROPSET(DAOField, put_OrdinalPosition, s);
  2070.     }
  2071.  
  2072. CString                CdbField::GetValidationText(
  2073.     VOID)
  2074.     {
  2075.     SPROPGET(DAOField, get_ValidationText);
  2076.     }
  2077.  
  2078. VOID                CdbField::SetValidationText(
  2079.     LPCTSTR pstr)
  2080.     {
  2081.     SPROPSET(DAOField, put_ValidationText, pstr);
  2082.     }
  2083.  
  2084. BOOL                CdbField::GetValidateOnSet(
  2085.     VOID)
  2086.     {
  2087.     BPROPGET(DAOField, get_ValidateOnSet);
  2088.     }
  2089.  
  2090. VOID                CdbField::SetValidateOnSet(
  2091.     BOOL b)
  2092.     {
  2093.     BPROPSET(DAOField, put_ValidateOnSet, b);
  2094.     }
  2095.  
  2096. CString                CdbField::GetValidationRule(
  2097.     VOID)
  2098.     {
  2099.     SPROPGET(DAOField, get_ValidationRule);
  2100.     }
  2101.  
  2102. VOID                CdbField::SetValidationRule(
  2103.     LPCTSTR pstr)
  2104.     {
  2105.     SPROPSET(DAOField, put_ValidationRule, pstr);
  2106.     }
  2107.  
  2108. CString                CdbField::GetDefaultValue(
  2109.     VOID)
  2110.     {
  2111.     SPROPGET(DAOField, get_DefaultValue);
  2112.     }
  2113.  
  2114. VOID                CdbField::SetDefaultValue(
  2115.     LPCTSTR pstr)
  2116.     {
  2117.     SPROPSET(DAOField, put_DefaultValue, pstr);
  2118.     }
  2119.  
  2120. BOOL                CdbField::GetRequired(
  2121.     VOID)
  2122.     {
  2123.     BPROPGET(DAOField, get_Required);
  2124.     }
  2125.  
  2126. VOID                CdbField::SetRequired(
  2127.     BOOL b)
  2128.     {
  2129.     BPROPSET(DAOField, put_Required, b);
  2130.     }
  2131.  
  2132. BOOL                CdbField::GetAllowZeroLength(
  2133.     VOID)
  2134.     {
  2135.     BPROPGET(DAOField, get_AllowZeroLength);
  2136.     }
  2137.  
  2138. VOID                CdbField::SetAllowZeroLength(
  2139.     BOOL b)
  2140.     {
  2141.     BPROPSET(DAOField, put_AllowZeroLength, b);
  2142.     }
  2143.  
  2144. BOOL                CdbField::GetDataUpdatable(
  2145.     VOID)
  2146.     {
  2147.     BPROPGET(DAOField, get_DataUpdatable);
  2148.     }
  2149.  
  2150. CString                CdbField::GetForeignName(
  2151.     VOID)
  2152.     {
  2153.     SPROPGET(DAOField, get_ForeignName);
  2154.     }
  2155.  
  2156. VOID                CdbField::SetForeignName(
  2157.     LPCTSTR pstr)
  2158.     {
  2159.     SPROPSET(DAOField, put_ForeignName, pstr);
  2160.     }
  2161.  
  2162. // Methods
  2163. VOID                CdbField::AppendChunk(
  2164.     LPVARIANT pv)
  2165.     {
  2166.     DAOField *        pfld    = (DAOField *)GetInterface();
  2167.  
  2168.     DAOMFC_CALL(pfld->AppendChunk(*pv));
  2169.     }
  2170.  
  2171. COleVariant            CdbField::GetChunk(
  2172.     LONG lOffset,
  2173.     LONG lBytes)
  2174.     {
  2175.     DAOField *        pfld    = (DAOField *)GetInterface();
  2176.     COleVariant        v;
  2177.  
  2178.     if (!pfld)
  2179.         return (LPVARIANT)NULL;
  2180.  
  2181.     VariantInit(&v);
  2182.     DAOMFC_CALL(pfld->GetChunk(lOffset, lBytes, &v));
  2183.  
  2184.     return &v;
  2185.     }
  2186.  
  2187. LONG                CdbField::FieldSize(
  2188.     VOID)
  2189.     {
  2190.     DAOField *        pfld    = (DAOField *)GetInterface();
  2191.     LONG            l        = 0;
  2192.  
  2193.     if (!pfld)
  2194.         return 0;
  2195.  
  2196.     DAOMFC_CALL(pfld->FieldSize(&l));
  2197.  
  2198.     return l;
  2199.     }
  2200.  
  2201. CdbProperty            CdbField::CreateProperty(
  2202.     LPCTSTR        pstrName,    // = NULL
  2203.     LONG        lType,        // = -1
  2204.     LPVARIANT    pvValue,    // = NULL
  2205.     BOOL        bDDL)        // = FALSE
  2206.     {
  2207.     DAOField *    pfld        = (DAOField *)GetInterface();
  2208.     DAOProperty *    pprp    = NULL;
  2209.  
  2210.     if (!pfld)
  2211.         return (DAOProperty *)NULL;
  2212.  
  2213.     DAOMFC_CALL(pfld->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
  2214.  
  2215.     return pprp;
  2216.     }
  2217.  
  2218. /*****************************************************************************
  2219. * CdbQueryDef
  2220. */
  2221. // Administration
  2222. CONSTRUCTOR            CdbQueryDef::CdbQueryDef(
  2223.     VOID)
  2224.     {
  2225.     }
  2226.  
  2227. CONSTRUCTOR            CdbQueryDef::CdbQueryDef(
  2228.     DAOQueryDef *    pqd,
  2229.     BOOL             bAddRef)    // FALSE
  2230.     {
  2231.     CdbOleObject::SetInterface((LPUNKNOWN)pqd, bAddRef);
  2232.     }
  2233.  
  2234. CONSTRUCTOR            CdbQueryDef::CdbQueryDef(
  2235.     const CdbQueryDef &o)
  2236.     {
  2237.     SetInterface(o.GetInterface(TRUE));
  2238.     }
  2239.  
  2240. CdbQueryDef &        CdbQueryDef::operator =(
  2241.     const CdbQueryDef &o)
  2242.     {
  2243.     SetInterface(o.GetInterface(TRUE));
  2244.     return *this;
  2245.     }
  2246.  
  2247. VOID                CdbQueryDef::OnInterfaceChange(
  2248.     VOID)
  2249.     {
  2250.     DAOQueryDef *    pqd        = (DAOQueryDef *)GetInterface();
  2251.     DAOProperties *    pprps    = NULL;
  2252.     DAOFields *        pflds    = NULL;
  2253.     DAOParameters *    pprms    = NULL;
  2254.  
  2255.     if (pqd)
  2256.         {
  2257.         pqd->get_Properties(&pprps);
  2258.         pqd->get_Fields(&pflds);
  2259.         pqd->get_Parameters(&pprms);
  2260.         }
  2261.  
  2262.     Properties.SetInterface(pprps);
  2263.     Fields.SetInterface(pflds);
  2264.     Parameters.SetInterface(pprms);
  2265.     }
  2266.  
  2267. // Properties
  2268. COleDateTime            CdbQueryDef::GetDateCreated(
  2269.     VOID)
  2270.     {
  2271.     DPROPGET(DAOQueryDef, get_DateCreated);
  2272.     }
  2273.  
  2274. COleDateTime            CdbQueryDef::GetLastUpdated(
  2275.     VOID)
  2276.     {
  2277.     DPROPGET(DAOQueryDef, get_LastUpdated);
  2278.     }
  2279.  
  2280. CString                CdbQueryDef::GetName(
  2281.     VOID)
  2282.     {
  2283.     SPROPGET(DAOQueryDef, get_Name);
  2284.     }
  2285.  
  2286. VOID                CdbQueryDef::SetName(
  2287.     LPCTSTR pstr)
  2288.     {
  2289.     SPROPSET(DAOQueryDef, put_Name, pstr);
  2290.     }
  2291.  
  2292. SHORT                CdbQueryDef::GetODBCTimeout(
  2293.     VOID)
  2294.     {
  2295.     WPROPGET(DAOQueryDef, get_ODBCTimeout);
  2296.     }
  2297.  
  2298. VOID                CdbQueryDef::SetODBCTimeout(
  2299.     SHORT s)
  2300.     {
  2301.     WPROPSET(DAOQueryDef, put_ODBCTimeout, s);
  2302.     }
  2303.  
  2304. SHORT                CdbQueryDef::GetType(
  2305.     VOID)
  2306.     {
  2307.     WPROPGET(DAOQueryDef, get_Type);
  2308.     }
  2309.  
  2310. CString                CdbQueryDef::GetSQL(
  2311.     VOID)
  2312.     {
  2313.     SPROPGET(DAOQueryDef, get_SQL);
  2314.     }
  2315.  
  2316. VOID                CdbQueryDef::SetSQL(
  2317.     LPCTSTR pstr)
  2318.     {
  2319.     SPROPSET(DAOQueryDef, put_SQL, pstr);
  2320.     }
  2321.  
  2322. BOOL                CdbQueryDef::GetUpdatable(
  2323.     VOID)
  2324.     {
  2325.     BPROPGET(DAOQueryDef, get_Updatable);
  2326.     }
  2327.  
  2328. CString                CdbQueryDef::GetConnect(
  2329.     VOID)
  2330.     {
  2331.     SPROPGET(DAOQueryDef, get_Connect);
  2332.     }
  2333.  
  2334. VOID                CdbQueryDef::SetConnect(
  2335.     LPCTSTR pstr)
  2336.     {
  2337.     SPROPSET(DAOQueryDef, put_Connect, pstr);
  2338.     }
  2339.  
  2340. BOOL                CdbQueryDef::GetReturnsRecords(
  2341.     VOID)
  2342.     {
  2343.     BPROPGET(DAOQueryDef, get_ReturnsRecords);
  2344.     }
  2345.  
  2346. VOID                CdbQueryDef::SetReturnsRecords(
  2347.     BOOL b)
  2348.     {
  2349.     BPROPSET(DAOQueryDef, put_ReturnsRecords, b);
  2350.     }
  2351.  
  2352. LONG                CdbQueryDef::GetRecordsAffected(
  2353.     VOID)
  2354.     {
  2355.     LPROPGET(DAOQueryDef, get_RecordsAffected);
  2356.     }
  2357.  
  2358. // Methods
  2359. CdbRecordset        CdbQueryDef::OpenRecordset(
  2360.     LONG lType,        // = -1
  2361.     LONG lOption)    // = -1
  2362.     {
  2363.     DAOQueryDef *    pqd = (DAOQueryDef *)GetInterface();
  2364.     DAORecordset *    prs    = NULL;
  2365.  
  2366.     if (!pqd)
  2367.         return (DAORecordset *)NULL;
  2368.  
  2369.     DAOMFC_CALL(pqd->OpenRecordset(OLTV(lType), OLTV(lOption), &prs));
  2370.  
  2371.     return prs;
  2372.     }
  2373.  
  2374. VOID                CdbQueryDef::Execute(
  2375.     LONG lOption)    // = -1
  2376.     {
  2377.     DAOQueryDef *    pqd = (DAOQueryDef *)GetInterface();
  2378.  
  2379.     DAOMFC_CALL(pqd->Execute(OLTV(lOption)));
  2380.     }
  2381.  
  2382. CdbProperty            CdbQueryDef::CreateProperty(
  2383.     LPCTSTR        pstrName,    // = NULL
  2384.     LONG        lType,        // = -1
  2385.     LPVARIANT    pvValue,    // = NULL
  2386.     BOOL        bDDL)        // = FALSE
  2387.     {
  2388.     DAOQueryDef *    pqd        = (DAOQueryDef *)GetInterface();
  2389.     DAOProperty *    pprp    = NULL;
  2390.  
  2391.     if (!pqd)
  2392.         return (DAOProperty *)NULL;
  2393.  
  2394.     DAOMFC_CALL(pqd->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
  2395.  
  2396.     return pprp;
  2397.     }
  2398.  
  2399. /*****************************************************************************
  2400. * CdbTableDef
  2401. */
  2402. // Administration
  2403. CONSTRUCTOR            CdbTableDef::CdbTableDef(
  2404.     VOID)
  2405.     {
  2406.     }
  2407.  
  2408. CONSTRUCTOR            CdbTableDef::CdbTableDef(
  2409.     DAOTableDef *    ptd,
  2410.     BOOL             bAddRef)    // = FALSE
  2411.     {
  2412.     CdbOleObject::SetInterface((LPUNKNOWN)ptd, bAddRef);
  2413.     }
  2414.  
  2415. CONSTRUCTOR            CdbTableDef::CdbTableDef(
  2416.     const CdbTableDef &o)
  2417.     {
  2418.     SetInterface(o.GetInterface(TRUE));
  2419.     }
  2420.  
  2421. CdbTableDef &        CdbTableDef::operator =(
  2422.     const CdbTableDef &o)
  2423.     {
  2424.     SetInterface(o.GetInterface(TRUE));
  2425.     return *this;
  2426.     }
  2427.  
  2428. VOID                CdbTableDef::OnInterfaceChange(
  2429.     VOID)
  2430.     {
  2431.     DAOTableDef *    ptd        = (DAOTableDef *)GetInterface();
  2432.     DAOProperties *    pprps    = NULL;
  2433.     DAOFields *        pflds    = NULL;
  2434.     DAOIndexes *    pidxs    = NULL;
  2435.  
  2436.     if (ptd)
  2437.         {
  2438.         ptd->get_Properties(&pprps);
  2439.         ptd->get_Fields(&pflds);
  2440.         ptd->get_Indexes(&pidxs);
  2441.         }
  2442.  
  2443.     Properties.SetInterface(pprps);
  2444.     Fields.SetInterface(pflds);
  2445.     Indexes.SetInterface(pidxs);
  2446.     }
  2447.  
  2448. // Properties
  2449. LONG                CdbTableDef::GetAttributes(
  2450.     VOID)
  2451.     {
  2452.     LPROPGET(DAOTableDef, get_Attributes);
  2453.     }
  2454.  
  2455. VOID                CdbTableDef::SetAttributes(
  2456.     LONG l)
  2457.     {
  2458.     LPROPSET(DAOTableDef, put_Attributes, l);
  2459.     }
  2460.  
  2461. CString                CdbTableDef::GetConnect(
  2462.     VOID)
  2463.     {
  2464.     SPROPGET(DAOTableDef, get_Connect);
  2465.     }
  2466.  
  2467. VOID                CdbTableDef::SetConnect(
  2468.     LPCTSTR pstr)
  2469.     {
  2470.     SPROPSET(DAOTableDef, put_Connect, pstr);
  2471.     }
  2472.  
  2473. COleDateTime            CdbTableDef::GetDateCreated(
  2474.     VOID)
  2475.     {
  2476.     DPROPGET(DAOTableDef, get_DateCreated);
  2477.     }
  2478.  
  2479. COleDateTime            CdbTableDef::GetLastUpdated(
  2480.     VOID)
  2481.     {
  2482.     DPROPGET(DAOTableDef, get_LastUpdated);
  2483.     }
  2484.  
  2485. CString                CdbTableDef::GetName(
  2486.     VOID)
  2487.     {
  2488.     SPROPGET(DAOTableDef, get_Name);
  2489.     }
  2490.  
  2491. VOID                CdbTableDef::SetName(
  2492.     LPCTSTR pstr)
  2493.     {
  2494.     SPROPSET(DAOTableDef, put_Name, pstr);
  2495.     }
  2496.  
  2497. CString                CdbTableDef::GetSourceTableName(
  2498.     VOID)
  2499.     {
  2500.     SPROPGET(DAOTableDef, get_SourceTableName);
  2501.     }
  2502.  
  2503. VOID                CdbTableDef::SetSourceTableName(
  2504.     LPCTSTR pstr)
  2505.     {
  2506.     SPROPSET(DAOTableDef, put_SourceTableName, pstr);
  2507.     }
  2508.  
  2509. BOOL                CdbTableDef::GetUpdatable(
  2510.     VOID)
  2511.     {
  2512.     BPROPGET(DAOTableDef, get_Updatable);
  2513.     }
  2514.  
  2515. CString                CdbTableDef::GetValidationText(
  2516.     VOID)
  2517.     {
  2518.     SPROPGET(DAOTableDef, get_ValidationText);
  2519.     }
  2520.  
  2521. VOID                CdbTableDef::SetValidationText(
  2522.     LPCTSTR pstr)
  2523.     {
  2524.     SPROPSET(DAOTableDef, put_ValidationText, pstr);
  2525.     }
  2526.  
  2527. CString                CdbTableDef::GetValidationRule(
  2528.     VOID)
  2529.     {
  2530.     SPROPGET(DAOTableDef, get_ValidationRule);
  2531.     }
  2532.  
  2533. VOID                CdbTableDef::SetValidationRule(
  2534.     LPCTSTR pstr)
  2535.     {
  2536.     SPROPSET(DAOTableDef, put_ValidationRule, pstr);
  2537.     }
  2538.  
  2539. LONG                CdbTableDef::GetRecordCount(
  2540.     VOID)
  2541.     {
  2542.     LPROPGET(DAOTableDef, get_RecordCount);
  2543.     }
  2544.  
  2545. // Methods
  2546. CdbRecordset        CdbTableDef::OpenRecordset(
  2547.     LONG lType,        // = -1
  2548.     LONG lOption)    // = -1
  2549.     {
  2550.     DAOTableDef *    ptd        = (DAOTableDef *)GetInterface();
  2551.     DAORecordset *    prs        = NULL;
  2552.  
  2553.     if (!ptd)
  2554.         return (DAORecordset *)NULL;
  2555.  
  2556.     DAOMFC_CALL(ptd->OpenRecordset(OLTV(lType), OLTV(lOption), &prs));
  2557.  
  2558.     return prs;
  2559.     }
  2560.  
  2561. VOID                CdbTableDef::RefreshLink(
  2562.     VOID)
  2563.     {
  2564.     DAOTableDef *    ptd        = (DAOTableDef *)GetInterface();
  2565.  
  2566.     DAOMFC_CALL(ptd->RefreshLink());
  2567.     }
  2568.  
  2569. CdbField            CdbTableDef::CreateField(
  2570.     LPCTSTR    pstrName,    // = NULL
  2571.     LONG    lType,        // = -1
  2572.     LONG    lSize)        // = -1
  2573.     {
  2574.     DAOTableDef *    ptd        = (DAOTableDef *)GetInterface();
  2575.     DAOField *        pfld    = NULL;
  2576.  
  2577.     if (!ptd)
  2578.         return (DAOField *)NULL;
  2579.  
  2580.     DAOMFC_CALL(ptd->CreateField(STV(pstrName), OLTV(lType), OLTV(lSize), &pfld));
  2581.  
  2582.     return pfld;
  2583.     }
  2584.  
  2585. CdbIndex            CdbTableDef::CreateIndex(
  2586.     LPCTSTR pstrName)    // = NULL
  2587.     {
  2588.     DAOTableDef *    ptd        = (DAOTableDef *)GetInterface();
  2589.     DAOIndex *        pidx    = NULL;
  2590.  
  2591.     if (!ptd)
  2592.         return (DAOIndex *)NULL;
  2593.  
  2594.     DAOMFC_CALL(ptd->CreateIndex(STV(pstrName), &pidx));
  2595.  
  2596.     return pidx;
  2597.     }
  2598.  
  2599. CdbProperty            CdbTableDef::CreateProperty(
  2600.     LPCTSTR        pstrName,    // = NULL
  2601.     LONG        lType,        // = -1
  2602.     LPVARIANT    pvValue,    // = NULL
  2603.     BOOL        bDDL)        // = FALSE
  2604.     {
  2605.     DAOTableDef *    ptd        = (DAOTableDef *)GetInterface();
  2606.     DAOProperty *    pprp    = NULL;
  2607.  
  2608.     if (!ptd)
  2609.         return (DAOProperty *)NULL;
  2610.  
  2611.     DAOMFC_CALL(ptd->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
  2612.  
  2613.     return pprp;
  2614.     }
  2615.  
  2616. /*****************************************************************************
  2617. * CdbIndex
  2618. */
  2619. // Administration
  2620. CONSTRUCTOR            CdbIndex::CdbIndex(
  2621.     VOID)
  2622.     {
  2623.     }
  2624.  
  2625. CONSTRUCTOR            CdbIndex::CdbIndex(
  2626.     DAOIndex *    pidx,
  2627.     BOOL         bAddRef)    // = FALSE
  2628.     {
  2629.     CdbOleObject::SetInterface((LPUNKNOWN)pidx, bAddRef);
  2630.     }
  2631.  
  2632. CONSTRUCTOR            CdbIndex::CdbIndex(
  2633.     const CdbIndex &o)
  2634.     {
  2635.     SetInterface(o.GetInterface(TRUE));
  2636.     }
  2637.  
  2638. CdbIndex &            CdbIndex::operator =(
  2639.     const CdbIndex &o)
  2640.     {
  2641.     SetInterface(o.GetInterface(TRUE));
  2642.     return *this;
  2643.     }
  2644.  
  2645. VOID                CdbIndex::OnInterfaceChange(
  2646.     VOID)
  2647.     {
  2648.     DAOIndex *        pidx    = (DAOIndex *)GetInterface();
  2649.     DAOProperties *    pprps    = NULL;
  2650.     DAOFields *        pflds    = NULL;
  2651.  
  2652.     if (pidx)
  2653.         {
  2654.         VARIANT    v;
  2655.  
  2656.         VariantInit(&v);
  2657.  
  2658.         pidx->get_Properties(&pprps);
  2659.         pidx->get_Fields(&v);
  2660.  
  2661.         v.pdispVal->QueryInterface(dbIID_IDAOIndexFields, (LPVOID *)&pflds);
  2662.         v.pdispVal->Release();
  2663.         }
  2664.  
  2665.     Properties.SetInterface(pprps);
  2666.     Fields.SetInterface(pflds);
  2667.     }
  2668.  
  2669. // Properties
  2670. CString                CdbIndex::GetName(
  2671.     VOID)
  2672.     {
  2673.     SPROPGET(DAOIndex, get_Name);
  2674.     }
  2675.  
  2676. VOID                CdbIndex::SetName(
  2677.     LPCTSTR pstr)
  2678.     {
  2679.     SPROPSET(DAOIndex, put_Name, pstr);
  2680.     }
  2681.  
  2682. BOOL                CdbIndex::GetForeign(
  2683.     VOID)
  2684.     {
  2685.     BPROPGET(DAOIndex, get_Foreign);
  2686.     }
  2687.  
  2688. BOOL                CdbIndex::GetUnique(
  2689.     VOID)
  2690.     {
  2691.     BPROPGET(DAOIndex, get_Unique);
  2692.     }
  2693.  
  2694. VOID                CdbIndex::SetUnique(
  2695.     BOOL b)
  2696.     {
  2697.     BPROPSET(DAOIndex, put_Unique, b);
  2698.     }
  2699.  
  2700. BOOL                CdbIndex::GetClustered(
  2701.     VOID)
  2702.     {
  2703.     BPROPGET(DAOIndex, get_Clustered);
  2704.     }
  2705.  
  2706. VOID                CdbIndex::SetClustered(
  2707.     BOOL b)
  2708.     {
  2709.     BPROPSET(DAOIndex, put_Clustered, b);
  2710.     }
  2711.  
  2712. BOOL                CdbIndex::GetRequired(
  2713.     VOID)
  2714.     {
  2715.     BPROPGET(DAOIndex, get_Required);
  2716.     }
  2717.  
  2718. VOID                CdbIndex::SetRequired(
  2719.     BOOL b)
  2720.     {
  2721.     BPROPSET(DAOIndex, put_Required, b);
  2722.     }
  2723.  
  2724. BOOL                CdbIndex::GetIgnoreNulls(
  2725.     VOID)
  2726.     {
  2727.     BPROPGET(DAOIndex, get_IgnoreNulls);
  2728.     }
  2729.  
  2730. VOID                CdbIndex::SetIgnoreNulls(
  2731.     BOOL b)
  2732.     {
  2733.     BPROPSET(DAOIndex, put_IgnoreNulls, b);
  2734.     }
  2735.  
  2736. BOOL                CdbIndex::GetPrimary(
  2737.     VOID)
  2738.     {
  2739.     BPROPGET(DAOIndex, get_Primary);
  2740.     }
  2741.  
  2742. VOID                CdbIndex::SetPrimary(
  2743.     BOOL b)
  2744.     {
  2745.     BPROPSET(DAOIndex, put_Primary, b);
  2746.     }
  2747.  
  2748. LONG                CdbIndex::GetDistinctCount(
  2749.     VOID)
  2750.     {
  2751.     LPROPGET(DAOIndex, get_DistinctCount);
  2752.     }
  2753.  
  2754.  
  2755. // Methods
  2756. CdbField            CdbIndex::CreateField(
  2757.     LPCTSTR    pstrName,    // = NULL
  2758.     LONG    lType,        // = -1
  2759.     LONG    lSize)        // = -1
  2760.     {
  2761.     DAOIndex *        pidx    = (DAOIndex *)GetInterface();
  2762.     DAOField *        pfld    = NULL;
  2763.  
  2764.     if (!pidx)
  2765.         return (DAOField *)NULL;
  2766.  
  2767.     DAOMFC_CALL(pidx->CreateField(STV(pstrName), OLTV(lType), OLTV(lSize), &pfld));
  2768.  
  2769.     return pfld;
  2770.     }
  2771.  
  2772. CdbProperty            CdbIndex::CreateProperty(
  2773.     LPCTSTR        pstrName,    // = NULL
  2774.     LONG        lType,        // = -1
  2775.     LPVARIANT    pvValue,    // = NULL
  2776.     BOOL        bDDL)        // = FALSE
  2777.     {
  2778.     DAOIndex *        pidx    = (DAOIndex *)GetInterface();
  2779.     DAOProperty *    pprp    = NULL;
  2780.  
  2781.     if (!pidx)
  2782.         return (DAOProperty *)NULL;
  2783.  
  2784.     DAOMFC_CALL(pidx->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
  2785.  
  2786.     return pprp;
  2787.     }
  2788.  
  2789.  
  2790. /*****************************************************************************
  2791. * CdbProperty
  2792. */
  2793. // Administration
  2794. CONSTRUCTOR            CdbProperty::CdbProperty(
  2795.     VOID)
  2796.     {
  2797.     }
  2798.  
  2799. CONSTRUCTOR            CdbProperty::CdbProperty(
  2800.     DAOProperty *    pprp,
  2801.     BOOL            bAddRef)    // = FALSE
  2802.     {
  2803.     SetInterface((LPUNKNOWN)pprp, bAddRef);
  2804.     }
  2805.  
  2806. CONSTRUCTOR            CdbProperty::CdbProperty(
  2807.     const CdbProperty &o)
  2808.     {
  2809.     SetInterface(o.GetInterface(TRUE));
  2810.     }
  2811.  
  2812. CdbProperty &        CdbProperty::operator =(
  2813.     const CdbProperty &o)
  2814.     {
  2815.     SetInterface(o.GetInterface(TRUE));
  2816.     return *this;
  2817.     }
  2818.  
  2819. // Properties
  2820. COleVariant            CdbProperty::GetValue(
  2821.     VOID)
  2822.     {
  2823.     DAOProperty *    pprp = (DAOProperty *)GetInterface();
  2824.     COleVariant        v;
  2825.  
  2826.     if (!pprp)
  2827.         return v;
  2828.  
  2829.     DAOMFC_CALL(pprp->get_Value((LPVARIANT)v));
  2830.  
  2831.     return v;
  2832.     }
  2833.  
  2834. VOID                CdbProperty::SetValue(
  2835.     LPVARIANT pv)
  2836.     {
  2837.     DAOProperty *    pprp = (DAOProperty *)GetInterface();
  2838.  
  2839.     DAOMFC_CALL(pprp->put_Value(*pv));
  2840.     }
  2841.  
  2842. CString                CdbProperty::GetName(
  2843.     VOID)
  2844.     {
  2845.     DAOProperty *    pprp = (DAOProperty *)GetInterface();
  2846.     CdbBSTR            bstr;
  2847.  
  2848.     if (!pprp)
  2849.         return (LPCTSTR)NULL;
  2850.  
  2851.     DAOMFC_CALL(pprp->get_Name(bstr));
  2852.  
  2853.     return bstr;
  2854.     }
  2855.  
  2856. VOID                CdbProperty::SetName(
  2857.     LPCTSTR pstrName)
  2858.     {
  2859.     DAOProperty *    pprp = (DAOProperty *)GetInterface();
  2860.  
  2861.     DAOMFC_CALL(pprp->put_Name(STB(pstrName)));
  2862.     }
  2863.  
  2864. SHORT                CdbProperty::GetType(
  2865.     VOID)
  2866.     {
  2867.     DAOProperty *    pprp     = (DAOProperty *)GetInterface();
  2868.     SHORT            s        = 0;
  2869.  
  2870.     if (!pprp)
  2871.         return 0;
  2872.  
  2873.     DAOMFC_CALL(pprp->get_Type(&s));
  2874.  
  2875.     return s;
  2876.     }
  2877.  
  2878. VOID                CdbProperty::SetType(
  2879.     SHORT sType)
  2880.     {
  2881.     DAOProperty *    pprp = (DAOProperty *)GetInterface();
  2882.  
  2883.     DAOMFC_CALL(pprp->put_Type(sType));
  2884.     }
  2885.  
  2886. BOOL                CdbProperty::GetInherited(
  2887.     VOID)
  2888.     {
  2889.     DAOProperty *    pprp    = (DAOProperty *)GetInterface();
  2890.     VARIANT_BOOL    vb        = 0;
  2891.  
  2892.     if (!pprp)
  2893.         return FALSE;
  2894.  
  2895.     DAOMFC_CALL(pprp->get_Inherited(&vb));
  2896.  
  2897.     return (BOOL)vb;
  2898.     }
  2899.  
  2900.  
  2901. /*****************************************************************************
  2902. * CdbParameter
  2903. */
  2904. // Administration
  2905. CONSTRUCTOR            CdbParameter::CdbParameter(
  2906.     VOID)
  2907.     {
  2908.     }
  2909.  
  2910. CONSTRUCTOR            CdbParameter::CdbParameter(
  2911.     DAOParameter *    pprm,
  2912.     BOOL             bAddRef)    // = FALSE
  2913.     {
  2914.     CdbOleObject::SetInterface((LPUNKNOWN)pprm, bAddRef);
  2915.     }
  2916.  
  2917. CONSTRUCTOR            CdbParameter::CdbParameter(
  2918.     const CdbParameter &o)
  2919.     {
  2920.     SetInterface(o.GetInterface(TRUE));
  2921.     }
  2922.  
  2923. CdbParameter &        CdbParameter::operator =(
  2924.     const CdbParameter &o)
  2925.     {
  2926.     SetInterface(o.GetInterface(TRUE));
  2927.     return *this;
  2928.     }
  2929.  
  2930. VOID                CdbParameter::OnInterfaceChange(
  2931.     VOID)
  2932.     {
  2933.     DAOParameter *    pprm    = (DAOParameter *)GetInterface();
  2934.     DAOProperties *    pprps    = NULL;
  2935.  
  2936.     if (pprm)
  2937.         pprm->get_Properties(&pprps);
  2938.  
  2939.     Properties.SetInterface(pprps);
  2940.     }
  2941.  
  2942. // Properties
  2943. CString                CdbParameter::GetName(
  2944.     VOID)
  2945.     {
  2946.     SPROPGET(DAOParameter, get_Name);
  2947.     }
  2948.  
  2949. COleVariant            CdbParameter::GetValue(
  2950.     VOID)
  2951.     {
  2952.     VPROPGET(DAOParameter, get_Value);
  2953.     }
  2954.  
  2955. VOID                CdbParameter::SetValue(
  2956.     LPVARIANT pv)
  2957.     {
  2958.     VPROPSET(DAOParameter, put_Value, pv);
  2959.     }
  2960.  
  2961. SHORT                CdbParameter::GetType(
  2962.     VOID)
  2963.     {
  2964.     WPROPGET(DAOParameter, get_Type);
  2965.     }
  2966.  
  2967.  
  2968. /*****************************************************************************
  2969. * CdbRelation
  2970. */
  2971. // Administration
  2972. CONSTRUCTOR            CdbRelation::CdbRelation(
  2973.     VOID)
  2974.     {
  2975.     }
  2976.  
  2977. CONSTRUCTOR            CdbRelation::CdbRelation(
  2978.     DAORelation *    prl,
  2979.     BOOL             bAddRef)    // = FALSE
  2980.     {
  2981.     CdbOleObject::SetInterface((LPUNKNOWN)prl, bAddRef);
  2982.     }
  2983.  
  2984. CONSTRUCTOR            CdbRelation::CdbRelation(
  2985.     const CdbRelation &o)
  2986.     {
  2987.     SetInterface(o.GetInterface(TRUE));
  2988.     }
  2989.  
  2990. CdbRelation &        CdbRelation::operator =(
  2991.     const CdbRelation &o)
  2992.     {
  2993.     SetInterface(o.GetInterface(TRUE));
  2994.     return *this;
  2995.     }
  2996.  
  2997. VOID                CdbRelation::OnInterfaceChange(
  2998.     VOID)
  2999.     {
  3000.     DAORelation *    prl        = (DAORelation *)GetInterface();
  3001.     DAOProperties *    pprps    = NULL;
  3002.     DAOFields *        pflds    = NULL;
  3003.  
  3004.     if (prl)
  3005.         {
  3006.         prl->get_Properties(&pprps);
  3007.         prl->get_Fields(&pflds);
  3008.         }
  3009.  
  3010.     Properties.SetInterface(pprps);
  3011.     Fields.SetInterface(pflds);
  3012.     }
  3013.  
  3014. // Properties
  3015. CString                CdbRelation::GetName(
  3016.     VOID)
  3017.     {
  3018.     SPROPGET(DAORelation, get_Name);
  3019.     }
  3020.  
  3021. VOID                CdbRelation::SetName(
  3022.     LPCTSTR pstr)
  3023.     {
  3024.     SPROPSET(DAORelation, put_Name, pstr);
  3025.     }
  3026.  
  3027. CString                CdbRelation::GetTable(
  3028.     VOID)
  3029.     {
  3030.     SPROPGET(DAORelation, get_Table);
  3031.     }
  3032.  
  3033. VOID                CdbRelation::SetTable(
  3034.     LPCTSTR pstr)
  3035.     {
  3036.     SPROPSET(DAORelation, put_Table, pstr);
  3037.     }
  3038.  
  3039. CString                CdbRelation::GetForeignTable(
  3040.     VOID)
  3041.     {
  3042.     SPROPGET(DAORelation, get_ForeignTable);
  3043.     }
  3044.  
  3045. VOID                CdbRelation::SetForeignTable(
  3046.     LPCTSTR pstr)
  3047.     {
  3048.     SPROPSET(DAORelation, put_ForeignTable, pstr);
  3049.     }
  3050.  
  3051. LONG                CdbRelation::GetAttributes(
  3052.     VOID)
  3053.     {
  3054.     LPROPGET(DAORelation, get_Attributes);
  3055.     }
  3056.  
  3057. VOID                CdbRelation::SetAttributes(
  3058.     LONG l)
  3059.     {
  3060.     LPROPSET(DAORelation, put_Attributes, l);
  3061.     }
  3062.  
  3063.  
  3064. // Methods
  3065. CdbField            CdbRelation::CreateField(
  3066.     LPCTSTR    pstrName,    // = NULL
  3067.     LONG    lType,        // = -1
  3068.     LONG    lSize)        // = -1
  3069.     {
  3070.     DAORelation *    prl        = (DAORelation *)GetInterface();
  3071.     DAOField *        pfld    = NULL;
  3072.  
  3073.     if (!prl)
  3074.         return (DAOField *)NULL;
  3075.  
  3076.     DAOMFC_CALL(prl->CreateField(STV(pstrName), OLTV(lType), OLTV(lSize), &pfld));
  3077.  
  3078.     return pfld;
  3079.     }
  3080.  
  3081.  
  3082. /*****************************************************************************
  3083. * CdbUser
  3084. */
  3085. // Administration
  3086. CONSTRUCTOR            CdbUser::CdbUser(
  3087.     VOID)
  3088.     {
  3089.     }
  3090.  
  3091. CONSTRUCTOR            CdbUser::CdbUser(
  3092.     DAOUser *    pusr,
  3093.     BOOL         bAddRef)    // = FALSE
  3094.     {
  3095.     CdbOleObject::SetInterface((LPUNKNOWN)pusr, bAddRef);
  3096.     }
  3097.  
  3098. CONSTRUCTOR            CdbUser::CdbUser(
  3099.     const CdbUser &o)
  3100.     {
  3101.     SetInterface(o.GetInterface(TRUE));
  3102.     }
  3103.  
  3104. CdbUser &            CdbUser::operator =(
  3105.     const CdbUser &o)
  3106.     {
  3107.     SetInterface(o.GetInterface(TRUE));
  3108.     return *this;
  3109.     }
  3110.  
  3111. VOID                CdbUser::OnInterfaceChange(
  3112.     VOID)
  3113.     {
  3114.     DAOUser *        pusr     = (DAOUser *)GetInterface();
  3115.     DAOProperties *    pprps    = NULL;
  3116.     DAOGroups *        pgrps    = NULL;
  3117.  
  3118.     if (pusr)
  3119.         {
  3120.         pusr->get_Properties(&pprps);
  3121.         pusr->get_Groups(&pgrps);
  3122.         }
  3123.  
  3124.     Properties.SetInterface(pprps);
  3125.     Groups.SetInterface(pgrps);
  3126.     }
  3127.  
  3128. // Properties
  3129. CString                CdbUser::GetName(
  3130.     VOID)
  3131.     {
  3132.     SPROPGET(DAOUser, get_Name);
  3133.     }
  3134.  
  3135. VOID                CdbUser::SetName(
  3136.     LPCTSTR pstr)
  3137.     {
  3138.     SPROPSET(DAOUser, put_Name, pstr);
  3139.     }
  3140.  
  3141. VOID                CdbUser::SetPID(
  3142.     LPCTSTR pstr)
  3143.     {
  3144.     SPROPSET(DAOUser, put_PID, pstr);
  3145.     }
  3146.  
  3147. VOID                CdbUser::SetPassword(
  3148.     LPCTSTR pstr)
  3149.     {
  3150.     SPROPSET(DAOUser, put_Password, pstr);
  3151.     }
  3152.  
  3153. // Methods
  3154. VOID                CdbUser::NewPassword(
  3155.     LPCTSTR    pstrOld,
  3156.     LPCTSTR    pstrNew)
  3157.     {
  3158.     DAOUser *        pusr     = (DAOUser *)GetInterface();
  3159.  
  3160.     DAOMFC_CALL(pusr->NewPassword(STB(pstrOld), STB(pstrNew)));
  3161.     }
  3162.  
  3163. CdbGroup            CdbUser::CreateGroup(
  3164.     LPCTSTR pstrName,    // = NULL
  3165.     LPCTSTR pstrPID)    // = NULL
  3166.     {
  3167.     DAOUser *        pusr     = (DAOUser *)GetInterface();
  3168.     DAOGroup *        pgrp    = NULL;
  3169.  
  3170.     if (!pusr)
  3171.         return FALSE;
  3172.  
  3173.     DAOMFC_CALL(pusr->CreateGroup(STV(pstrName), STV(pstrPID), &pgrp));
  3174.  
  3175.     return pgrp;
  3176.     }
  3177.  
  3178. /*****************************************************************************
  3179. * CdbGroup
  3180. */
  3181. // Administration
  3182. CONSTRUCTOR            CdbGroup::CdbGroup(
  3183.     VOID)
  3184.     {
  3185.     }
  3186.  
  3187. CONSTRUCTOR            CdbGroup::CdbGroup(
  3188.     DAOGroup *    pgrp,
  3189.     BOOL         bAddRef)    // = FALSE
  3190.     {
  3191.     CdbOleObject::SetInterface((LPUNKNOWN)pgrp, bAddRef);
  3192.     }
  3193.  
  3194. CONSTRUCTOR            CdbGroup::CdbGroup(
  3195.     const CdbGroup &o)
  3196.     {
  3197.     SetInterface(o.GetInterface(TRUE));
  3198.     }
  3199.  
  3200. CdbGroup &            CdbGroup::operator =(
  3201.     const CdbGroup &o)
  3202.     {
  3203.     SetInterface(o.GetInterface(TRUE));
  3204.     return *this;
  3205.     }
  3206.  
  3207. VOID                CdbGroup::OnInterfaceChange(
  3208.     VOID)
  3209.     {
  3210.     DAOGroup *        pgrp     = (DAOGroup *)GetInterface();
  3211.     DAOProperties *    pprps    = NULL;
  3212.     DAOUsers *        pusrs    = NULL;
  3213.  
  3214.     if (pgrp)
  3215.         {
  3216.         pgrp->get_Properties(&pprps);
  3217.         pgrp->get_Users(&pusrs);
  3218.         }
  3219.  
  3220.     Properties.SetInterface(pprps);
  3221.     Users.SetInterface(pusrs);
  3222.     }
  3223.  
  3224. // Properties
  3225. CString                CdbGroup::GetName(
  3226.     VOID)
  3227.     {
  3228.     SPROPGET(DAOGroup, get_Name);
  3229.     }
  3230.  
  3231. VOID                CdbGroup::SetName(
  3232.     LPCTSTR pstr)
  3233.     {
  3234.     SPROPSET(DAOGroup, put_Name, pstr);
  3235.     }
  3236.  
  3237. VOID                CdbGroup::SetPID(
  3238.     LPCTSTR pstr)
  3239.     {
  3240.     SPROPSET(DAOGroup, put_PID, pstr);
  3241.     }
  3242.  
  3243. // Methods
  3244. CdbUser                CdbGroup::CreateUser(
  3245.     LPCTSTR pstrName,        // = NULL
  3246.     LPCTSTR pstrPID,        // = NULL
  3247.     LPCTSTR    pstrPassword)    // = NULL
  3248.     {
  3249.     DAOGroup *        pgrp     = (DAOGroup *)GetInterface();
  3250.     DAOUser *        pusr    = NULL;
  3251.  
  3252.     if (!pgrp)
  3253.         return FALSE;
  3254.  
  3255.     DAOMFC_CALL(pgrp->CreateUser(STV(pstrName), STV(pstrPID), STV(pstrPassword), &pusr));
  3256.  
  3257.     return pusr;
  3258.     }
  3259.  
  3260.  
  3261. /*****************************************************************************
  3262. * CdbDocument
  3263. */
  3264. // Administration
  3265. CONSTRUCTOR            CdbDocument::CdbDocument(
  3266.     VOID)
  3267.     {
  3268.     }
  3269.  
  3270. CONSTRUCTOR            CdbDocument::CdbDocument(
  3271.     DAODocument *    pdoc,
  3272.     BOOL             bAddRef)    // = FALSE
  3273.     {
  3274.     CdbOleObject::SetInterface((LPUNKNOWN)pdoc, bAddRef);
  3275.     }
  3276.  
  3277. CONSTRUCTOR            CdbDocument::CdbDocument(
  3278.     const CdbDocument &o)
  3279.     {
  3280.     SetInterface(o.GetInterface(TRUE));
  3281.     }
  3282.  
  3283. CdbDocument &        CdbDocument::operator =(
  3284.     const CdbDocument &o)
  3285.     {
  3286.     SetInterface(o.GetInterface(TRUE));
  3287.     return *this;
  3288.     }
  3289.  
  3290. VOID                CdbDocument::OnInterfaceChange(
  3291.     VOID)
  3292.     {
  3293.     DAODocument *    pdoc    = (DAODocument *)GetInterface();
  3294.     DAOProperties *    pprps    = NULL;
  3295.  
  3296.     if (pdoc)
  3297.         {
  3298.         pdoc->get_Properties(&pprps);
  3299.         }
  3300.  
  3301.     Properties.SetInterface(pprps);
  3302.     }
  3303.  
  3304. // Properties
  3305. CString                CdbDocument::GetName(
  3306.     VOID)
  3307.     {
  3308.     SPROPGET(DAODocument, get_Name);
  3309.     }
  3310.  
  3311. CString                CdbDocument::GetOwner(
  3312.     VOID)
  3313.     {
  3314.     SPROPGET(DAODocument, get_Owner);
  3315.     }
  3316.  
  3317. VOID                CdbDocument::SetOwner(
  3318.     LPCTSTR pstr)
  3319.     {
  3320.     SPROPSET(DAODocument, put_Owner, pstr);
  3321.     }
  3322.  
  3323. CString                CdbDocument::GetContainer(
  3324.     VOID)
  3325.     {
  3326.     SPROPGET(DAODocument, get_Container);
  3327.     }
  3328.  
  3329. CString                CdbDocument::GetUserName(
  3330.     VOID)
  3331.     {
  3332.     SPROPGET(DAODocument, get_UserName);
  3333.     }
  3334.  
  3335. VOID                CdbDocument::SetUserName(
  3336.     LPCTSTR pstr)
  3337.     {
  3338.     SPROPSET(DAODocument, put_UserName, pstr);
  3339.     }
  3340.  
  3341. LONG                CdbDocument::GetPermissions(
  3342.     VOID)
  3343.     {
  3344.     LPROPGET(DAODocument, get_Permissions);
  3345.     }
  3346.  
  3347. VOID                CdbDocument::SetPermissions(
  3348.     LONG l)
  3349.     {
  3350.     LPROPSET(DAODocument, put_Permissions, l);
  3351.     }
  3352.  
  3353. COleDateTime            CdbDocument::GetDateCreated(
  3354.     VOID)
  3355.     {
  3356.     DPROPGET(DAODocument, get_DateCreated);
  3357.     }
  3358.  
  3359. COleDateTime            CdbDocument::GetLastUpdated(
  3360.     VOID)
  3361.     {
  3362.     DPROPGET(DAODocument, get_LastUpdated);
  3363.     }
  3364.  
  3365.  
  3366. /*****************************************************************************
  3367. * CdbContainer
  3368. */
  3369. // Administration
  3370. CONSTRUCTOR            CdbContainer::CdbContainer(
  3371.     VOID)
  3372.     {
  3373.     }
  3374.  
  3375. CONSTRUCTOR            CdbContainer::CdbContainer(
  3376.     DAOContainer *    pctn,
  3377.     BOOL            bAddRef)    // = FALSE
  3378.     {
  3379.     CdbOleObject::SetInterface((LPUNKNOWN)pctn, bAddRef);
  3380.     }
  3381.  
  3382. CONSTRUCTOR            CdbContainer::CdbContainer(
  3383.     const CdbContainer &o)
  3384.     {
  3385.     SetInterface(o.GetInterface(TRUE));
  3386.     }
  3387.  
  3388. CdbContainer &        CdbContainer::operator =(
  3389.     const CdbContainer &o)
  3390.     {
  3391.     SetInterface(o.GetInterface(TRUE));
  3392.     return *this;
  3393.     }
  3394.  
  3395. VOID                CdbContainer::OnInterfaceChange(
  3396.     VOID)
  3397.     {
  3398.     DAOContainer *    pctn    = (DAOContainer *)GetInterface();
  3399.     DAOProperties *    pprps    = NULL;
  3400.     DAODocuments *    pdocs    = NULL;
  3401.  
  3402.     if (pctn)
  3403.         {
  3404.         pctn->get_Properties(&pprps);
  3405.         pctn->get_Documents(&pdocs);
  3406.         }
  3407.  
  3408.     Properties.SetInterface(pprps);
  3409.     Documents.SetInterface(pdocs);
  3410.     }
  3411.  
  3412. // Properties
  3413. CString                CdbContainer::GetName(
  3414.     VOID)
  3415.     {
  3416.     SPROPGET(DAOContainer, get_Name);
  3417.     }
  3418.  
  3419. CString                CdbContainer::GetOwner(
  3420.     VOID)
  3421.     {
  3422.     SPROPGET(DAOContainer, get_Owner);
  3423.     }
  3424.  
  3425. VOID                CdbContainer::SetOwner(
  3426.     LPCTSTR pstr)
  3427.     {
  3428.     SPROPSET(DAOContainer, put_Owner, pstr);
  3429.     }
  3430.  
  3431. CString                CdbContainer::GetUserName(
  3432.     VOID)
  3433.     {
  3434.     SPROPGET(DAOContainer, get_UserName);
  3435.     }
  3436.  
  3437. VOID                CdbContainer::SetUserName(
  3438.     LPCTSTR pstr)
  3439.     {
  3440.     SPROPSET(DAOContainer, put_UserName, pstr);
  3441.     }
  3442.  
  3443. LONG                CdbContainer::GetPermissions(
  3444.     VOID)
  3445.     {
  3446.     LPROPGET(DAOContainer, get_Permissions);
  3447.     }
  3448.  
  3449. VOID                CdbContainer::SetPermissions(
  3450.     LONG l)
  3451.     {
  3452.     LPROPSET(DAOContainer, put_Permissions, l);
  3453.     }
  3454.  
  3455. BOOL                CdbContainer::GetInherit(
  3456.     VOID)
  3457.     {
  3458.     BPROPGET(DAOContainer, get_Inherit);
  3459.     }
  3460.  
  3461. VOID                CdbContainer::SetInherit(
  3462.     BOOL b)
  3463.     {
  3464.     BPROPSET(DAOContainer, put_Inherit, b);
  3465.     }
  3466.  
  3467. /*****************************************************************************
  3468. * CdbIndexFields (special case for index fields)
  3469. */
  3470. CdbField            CdbIndexFields::Item(
  3471.     LPCTSTR pstr)
  3472.     {
  3473.     DAOIndexFields *    pflds    = (DAOIndexFields *)GetInterface();
  3474.     VARIANT                v;
  3475.     DAOField *            pfld    = NULL;
  3476.  
  3477.     if (!pflds)
  3478.         return (DAOField *)NULL;
  3479.  
  3480.     VariantInit(&v);
  3481.     DAOMFC_CALL(pflds->get_Item(STV(pstr), &v));
  3482.  
  3483.     if (v.vt == VT_DISPATCH)
  3484.         {
  3485.         v.pdispVal->QueryInterface(dbIID_IDAOField, (LPVOID *)&pfld);
  3486.         v.pdispVal->Release();
  3487.         }
  3488.  
  3489.     return pfld;
  3490.     }
  3491.  
  3492. CdbField            CdbIndexFields::Item(
  3493.     LONG i)
  3494.     {
  3495.     DAOIndexFields *    pflds    = (DAOIndexFields *)GetInterface();
  3496.     VARIANT                v;
  3497.     DAOField *            pfld    = NULL;
  3498.  
  3499.     if (!pflds)
  3500.         return (DAOField *)NULL;
  3501.  
  3502.     VariantInit(&v);
  3503.     DAOMFC_CALL(pflds->get_Item(LTV(i), &v));
  3504.  
  3505.     if (v.vt == VT_DISPATCH)
  3506.         {
  3507.         v.pdispVal->QueryInterface(dbIID_IDAOField, (LPVOID *)&pfld);
  3508.         v.pdispVal->Release();
  3509.         }
  3510.  
  3511.     return pfld;
  3512.     }
  3513.  
  3514. CdbObject            CdbIndexFields::ObItem(
  3515.     LPCTSTR pstr)
  3516.     {
  3517.     DAOIndexFields *    pflds    = (DAOIndexFields *)GetInterface();
  3518.     VARIANT                v;
  3519.     DAOField *            pfld    = NULL;
  3520.  
  3521.     if (!pflds)
  3522.         return (DAOFields *)NULL;
  3523.  
  3524.     VariantInit(&v);
  3525.     DAOMFC_CALL(pflds->get_Item(STV(pstr), &v));
  3526.  
  3527.     if (v.vt == VT_DISPATCH)
  3528.         {
  3529.         v.pdispVal->QueryInterface(dbIID_IDAOField, (LPVOID *)&pfld);
  3530.         v.pdispVal->Release();
  3531.         }
  3532.  
  3533.     return (LPUNKNOWN)pfld;
  3534.     }
  3535.  
  3536. CdbObject            CdbIndexFields::ObItem(
  3537.     LONG i)
  3538.     {
  3539.     DAOIndexFields *    pflds    = (DAOIndexFields *)GetInterface();
  3540.     VARIANT                v;
  3541.     DAOField *            pfld    = NULL;
  3542.  
  3543.     if (!pflds)
  3544.         return (DAOFields *)NULL;
  3545.  
  3546.     VariantInit(&v);
  3547.     DAOMFC_CALL(pflds->get_Item(LTV(i), &v));
  3548.  
  3549.     if (v.vt == VT_DISPATCH)
  3550.         {
  3551.         v.pdispVal->QueryInterface(dbIID_IDAOField, (LPVOID *)&pfld);
  3552.         v.pdispVal->Release();
  3553.         }
  3554.  
  3555.     return (LPUNKNOWN)pfld;
  3556.     }
  3557.  
  3558.  
  3559.  
  3560. /*****************************************************************************
  3561. * CdbBSTR
  3562. */
  3563. CONSTRUCTOR            CdbBSTR::CdbBSTR(
  3564.     BSTR    b)    // = NULL
  3565.     {
  3566.     m_bstr = b;
  3567.     }
  3568.  
  3569. DESTRUCTOR            CdbBSTR::~CdbBSTR(
  3570.     VOID)
  3571.     {
  3572.     if (m_bstr)
  3573.         SysFreeString(m_bstr);
  3574.     }
  3575.  
  3576.                     CdbBSTR::operator BSTR *(
  3577.     VOID)
  3578.     {
  3579.     return &m_bstr;
  3580.     }
  3581.  
  3582.                     CdbBSTR::operator LPCTSTR(
  3583.     VOID)
  3584.     {
  3585.     return (LPCTSTR)m_bstr;
  3586.     }
  3587.  
  3588. HRESULT                        CdbWideFromAnsi(
  3589.     LPSTR            pstr,
  3590.     unsigned int    cb,
  3591.     BSTR *            pbstr)
  3592.     {
  3593.     BSTR            bstrNew;
  3594.  
  3595.     if (!(bstrNew = SysAllocStringLen(NULL, cb)))
  3596.         return ResultFromScode(E_OUTOFMEMORY);
  3597.     
  3598.     // Convert from ANSI to WIDE if char.s exist
  3599.     if (cb && !(cb = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pstr,
  3600.         cb, (LPWSTR)bstrNew, cb)))
  3601.         {
  3602.         SysFreeString(bstrNew);
  3603.         return ResultFromScode(E_OUTOFMEMORY);
  3604.         }
  3605.  
  3606.     // Make sure it's NULL terminated
  3607.     ((LPWSTR)(bstrNew))[cb] = L'\0';
  3608.  
  3609.     *pbstr = bstrNew;
  3610.  
  3611.     return NOERROR;
  3612.     }
  3613.