home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- ** D B D A O . C P P *
- ** *
- *************************************************************************
- ** Copyright (C) 1995 by Microsoft Corporation *
- ** All Rights Reserved *
- ************************************************************************/
- /*
- DBDAO.CPP
-
- Source code for dbdao C++ classes
- */
-
- #include "stdafx.h"
- #include "resource.h"
-
- #define _DB_NOFORCE_LIBS
- #include <dbdao.h>
-
-
-
- /*****************************************************************************
- * CdbException
- */
- CONSTRUCTOR CdbException::CdbException(
- HRESULT hr)
- {
- m_hr = hr;
- }
-
- /*****************************************************************************
- * CdbBookmark
- */
- CONSTRUCTOR CdbBookmark::CdbBookmark() //default
- {
- vt = 0;
- parray = NULL;
- }
-
-
- CONSTRUCTOR CdbBookmark::CdbBookmark(
- LPSAFEARRAY psa)
- {
- vt = VT_ARRAY|VT_UI1;
- parray = psa;
- }
-
- CdbBookmark::operator LPSAFEARRAY(
- VOID)
- {
- return (vt&VT_ARRAY?parray:NULL);
- }
-
- /*****************************************************************************
- * CdbOleObject
- */
- CONSTRUCTOR CdbOleObject::CdbOleObject(
- VOID)
- {
- m_punkInterface = NULL;
- }
-
- CdbOleObject & CdbOleObject::operator =(
- CdbOleObject &o)
- {
- SetInterface(o.m_punkInterface, TRUE);
- return *this;
- }
-
- DESTRUCTOR CdbOleObject::~CdbOleObject(
- VOID)
- {
-
- if (m_punkInterface)
- m_punkInterface->Release();
- }
-
- BOOL CdbOleObject::StartOLE(
- )
- {
- HRESULT hr;
-
- DAOMFC_CALL(hr=CoInitialize(NULL));
-
- return SUCCEEDED(hr);
- }
-
- VOID CdbOleObject::SetInterface(
- LPUNKNOWN punk,
- BOOL bAddRef) // = FALSE
- {
- // Get rid of existing interface, if we have one
- if (m_punkInterface)
- m_punkInterface->Release();
-
- // Addref new interface so we have a valid reference
- if (bAddRef && punk)
- punk->AddRef();
-
- m_punkInterface = punk;
- OnInterfaceChange();
- }
-
- VOID CdbOleObject::SetInterface(
- REFIID riidClass,
- REFIID riidInterface)
- {
- LPUNKNOWN punk;
-
- if (!StartOLE())
- return;
-
- DAOMFC_CALL(CoCreateInstance(riidClass, NULL, CLSCTX_INPROC_SERVER, riidInterface, (LPVOID *)&punk));
-
- SetInterface(punk);
- }
-
- VOID CdbOleObject::SetInterfaceLic(
- REFIID riidClass,
- REFIID riidInterface)
- {
- LPUNKNOWN punk;
- BSTR m_bstrKey = NULL;
- LPCLASSFACTORY2 pClassFactory2 = NULL;
-
- if (!StartOLE())
- return;
-
- #if _MSC_VER >= 1000
- m_bstrKey = SysAllocString(CdbWide((LPSTR)szKEY));
- #else
- m_bstrKey = SysAllocString(_T(szKEY));
- #endif
-
- DAOMFC_CALL(CoGetClassObject(riidClass, CLSCTX_INPROC_SERVER, NULL, IID_IClassFactory2, (void**)&pClassFactory2));
-
- ASSERT(pClassFactory2 != NULL);
-
- DAOMFC_CALL(pClassFactory2->CreateInstanceLic(NULL, NULL, riidInterface, m_bstrKey,(LPVOID *)&punk));
-
- if (NULL!=m_bstrKey)
- SysFreeString(m_bstrKey);
-
- SetInterface(punk);
- }
-
-
- LPUNKNOWN CdbOleObject::GetInterface(
- BOOL bAddRef, // = FALSE
- BOOL bThrowException) const // = TRUE
- {
- if (!m_punkInterface)
- {
- // Oops! The OLE interface has not been set yet a request is
- // being made to access the interface!
-
- if (bThrowException)
- {
- // First: Set the rich error info.
- #if _MSC_VER >= 1000
- SetRichErrorInfo(L"DBDAO", L"Object OLE interface not set.", NULL, 0L);
- #endif
- // Second: Throw an exception.
- DAOMFC_CALL(E_FAIL);
- }
- else
- return NULL;
- }
-
- if (bAddRef)
- m_punkInterface->AddRef();
-
- return m_punkInterface;
- }
-
- VOID CdbOleObject::OnInterfaceChange(
- VOID)
- {
- // By default do nothing on interface change
- }
-
- VOID CdbOleObject::SetRichErrorInfo(
- LPOLESTR pstrSource,
- LPOLESTR pstrDescription,
- LPOLESTR pstrHelpFile,
- ULONG ulHelpID) const
- {
- ICreateErrorInfo * pcei;
- IErrorInfo * pei;
-
- if (FAILED(CreateErrorInfo(&pcei)))
- return;
-
- if (FAILED(pcei->QueryInterface(IID_IErrorInfo, (LPVOID *)&pei)))
- {
- pcei->Release();
- return;
- }
-
- pcei->SetGUID(IID_NULL);
-
- if (pstrSource)
- pcei->SetSource(pstrSource);
- if (pstrDescription)
- pcei->SetDescription(pstrDescription);
- if (pstrHelpFile)
- pcei->SetHelpFile(pstrHelpFile);
-
- pcei->SetHelpContext(ulHelpID);
-
- SetErrorInfo((DWORD)0, pei);
-
- pei->Release();
- pcei->Release();
- }
-
-
- /*****************************************************************************
- * CdbObject
- */
- CONSTRUCTOR CdbObject::CdbObject(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbObject::CdbObject(
- LPUNKNOWN punk,
- BOOL bAddRef) // = FALSE
- {
- SetInterface(punk, bAddRef);
- }
-
- CString CdbObject::GetName(
- VOID)
- {
- #if _MSC_VER >= 1000
- SetRichErrorInfo(L"DBDAO", L"Method not supported", NULL, 0);
- #endif
- DAOMFC_CALL(E_FAIL);
- return (LPCTSTR)NULL;
- }
-
- VOID CdbObject::SetName(
- LPCTSTR pstr)
- {
- UNREFERENCED_PARAMETER(pstr);
- #if _MSC_VER >= 1000
- SetRichErrorInfo(L"DBDAO", L"Method not supported", NULL, 0);
- #endif
- DAOMFC_CALL(E_FAIL);
- }
-
- /*****************************************************************************
- * CdbStaticCollection
- */
- // Methods
- CdbObject CdbStaticCollection::ObItem(
- LONG i)
- {
- DAOMFCSCollection * pcol = (DAOMFCSCollection *)GetInterface();
- LPUNKNOWN pint = NULL;
-
- if (!pcol)
- return (LPUNKNOWN)NULL;
-
- DAOMFC_CALL(pcol->get_Item(LTV(i), &pint));
-
- return pint;
- }
-
- CdbObject CdbStaticCollection::ObItem(
- LPCTSTR pstr)
- {
- DAOMFCSCollection * pcol = (DAOMFCSCollection *)GetInterface();
- LPUNKNOWN pint = NULL;
-
- if (!pcol)
- return (LPUNKNOWN)NULL;
-
- DAOMFC_CALL(pcol->get_Item(STV(pstr), &pint));
-
- return pint;
- }
-
- LONG CdbStaticCollection::GetCount(
- VOID)
- {
- DAOMFCSCollection * pcol = (DAOMFCSCollection *)GetInterface();
- SHORT s = 0;
-
- if (!pcol)
- return 0;
-
- DAOMFC_CALL(pcol->get_Count(&s));
-
- return (LONG)s;
- }
-
- VOID CdbStaticCollection::ObAppend(
- CdbObject &o)
- {
- UNREFERENCED_PARAMETER(o);
- }
-
- VOID CdbStaticCollection::Delete(
- LPCTSTR pstr)
- {
- UNREFERENCED_PARAMETER(pstr);
- }
-
- VOID CdbStaticCollection::Refresh(
- VOID)
- {
- DAOMFCSCollection * pcol = (DAOMFCSCollection *)GetInterface();
-
- DAOMFC_CALL(pcol->Refresh());
- }
-
- /*****************************************************************************
- * CdbDynamicCollection
- */
- // Methods
- CdbObject CdbDynamicCollection::ObItem(
- LONG i)
- {
- DAOMFCDCollection * pcol = (DAOMFCDCollection *)GetInterface();
- LPUNKNOWN pint = NULL;
-
- if (!pcol)
- return (LPUNKNOWN)NULL;
-
- DAOMFC_CALL(pcol->get_Item(LTV(i), &pint));
-
- return pint;
- }
-
- CdbObject CdbDynamicCollection::ObItem(
- LPCTSTR pstr)
- {
- DAOMFCDCollection * pcol = (DAOMFCDCollection *)GetInterface();
- LPUNKNOWN pint = NULL;
-
- if (!pcol)
- return (LPUNKNOWN)NULL;
-
- DAOMFC_CALL(pcol->get_Item(STV(pstr), &pint));
-
- return pint;
- }
-
- LONG CdbDynamicCollection::GetCount(
- VOID)
- {
- DAOMFCDCollection * pcol = (DAOMFCDCollection *)GetInterface();
- SHORT s = 0;
-
- if (!pcol)
- return 0;
-
- DAOMFC_CALL(pcol->get_Count(&s));
-
- return (LONG)s;
- }
-
- VOID CdbDynamicCollection::ObAppend(
- CdbObject &o)
- {
- DAOMFCDCollection * pcol = (DAOMFCDCollection *)GetInterface();
- LPDISPATCH pdisp = (LPDISPATCH)o.GetInterface();
-
- if (!pdisp)
- return;
-
- DAOMFC_CALL(pcol->Append(pdisp));
- }
-
- VOID CdbDynamicCollection::Delete(
- LPCTSTR pstr)
- {
- DAOMFCDCollection * pcol = (DAOMFCDCollection *)GetInterface();
-
- DAOMFC_CALL(pcol->Delete(STB(pstr)));
- }
-
- VOID CdbDynamicCollection::Refresh(
- VOID)
- {
- DAOMFCDCollection * pcol = (DAOMFCDCollection *)GetInterface();
-
- DAOMFC_CALL(pcol->Refresh());
- }
-
-
- /*****************************************************************************
- * Collection implementations
- */
- DAOMFC_STATIC_COLLECTION_IMPL(CdbErrors, CdbError, DAOErrors, DAOError)
- DAOMFC_STATIC_COLLECTION_IMPL(CdbDatabases, CdbDatabase, DAODatabases, DAODatabase)
- DAOMFC_STATIC_COLLECTION_IMPL(CdbRecordsets, CdbRecordset, DAORecordsets, DAORecordset)
- DAOMFC_STATIC_COLLECTION_IMPL(CdbParameters, CdbParameter, DAOParameters, DAOParameter)
- DAOMFC_STATIC_COLLECTION_IMPL(CdbDocuments, CdbDocument, DAODocuments, DAODocument)
- DAOMFC_STATIC_COLLECTION_IMPL(CdbContainers, CdbContainer, DAOContainers, DAOContainer)
-
- DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbProperties, CdbProperty, DAOProperties, DAOProperty)
- DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbWorkspaces, CdbWorkspace, DAOWorkspaces, DAOWorkspace)
- DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbFields, CdbField, DAOFields, DAOField)
- DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbQueryDefs, CdbQueryDef, DAOQueryDefs, DAOQueryDef)
- DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbTableDefs, CdbTableDef, DAOTableDefs, DAOTableDef)
- DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbIndexes, CdbIndex, DAOIndexes, DAOIndex)
- DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbRelations, CdbRelation, DAORelations, DAORelation)
- DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbUsers, CdbUser, DAOUsers, DAOUser)
- DAOMFC_DYNAMIC_COLLECTION_IMPL(CdbGroups, CdbGroup, DAOGroups, DAOGroup)
-
- /*****************************************************************************
- * CdbLastOLEError
- *
- * NOTE: This object is meant to be used inside of exception handlers so
- * exceptions should not be raised by these member functions.
- */
- CONSTRUCTOR CdbLastOLEError::CdbLastOLEError(
- VOID)
- {
- IErrorInfo * pei = NULL;
-
- GetErrorInfo(0L, &pei);
-
- CdbOleObject::SetInterface((LPUNKNOWN)pei);
- }
-
- CString CdbLastOLEError::GetSource(
- VOID)
- {
- IErrorInfo * pei = (IErrorInfo *)GetInterface(FALSE, FALSE);
- CdbBSTR bstr;
-
- if (!pei)
- return (LPOLESTR)NULL;
-
- pei->GetSource(bstr);
-
- return *((BSTR *)bstr);
- }
-
- CString CdbLastOLEError::GetDescription(
- VOID)
- {
- IErrorInfo * pei = (IErrorInfo *)GetInterface(FALSE, FALSE);
- CdbBSTR bstr;
-
- if (!pei)
- return (LPOLESTR)NULL;
-
- pei->GetDescription(bstr);
-
- return *((BSTR *)bstr);
- }
-
- CString CdbLastOLEError::GetHelpFile(
- VOID)
- {
- IErrorInfo * pei = (IErrorInfo *)GetInterface(FALSE, FALSE);
- CdbBSTR bstr;
-
- if (!pei)
- return (LPOLESTR)NULL;
-
- pei->GetHelpFile(bstr);
-
- return *((BSTR *)bstr);
- }
-
- DWORD CdbLastOLEError::GetHelpContext(
- VOID)
- {
- IErrorInfo * pei = (IErrorInfo *)GetInterface(FALSE, FALSE);
- DWORD dw = 0;
-
- if (!pei)
- return 0;
-
- pei->GetHelpContext(&dw);
-
- return dw;
- }
-
- /*****************************************************************************
- * CdbDBEngine
- */
- // Administration
- CONSTRUCTOR CdbDBEngine::CdbDBEngine(
- DAODBEngine * peng,
- BOOL bAddRef) // = FALSE
- {
- m_bStarted = TRUE;
- CdbOleObject::SetInterface((LPUNKNOWN)peng, bAddRef);
- }
-
- CONSTRUCTOR CdbDBEngine::CdbDBEngine(
- BOOL bPrivate, // = FALSE
- BOOL bStart, // = TRUE
- LPCTSTR pstrIniPath, // = NULL
- LPCTSTR pstrDefUser, // = NULL
- LPCTSTR pstrDefPW) // = NULL
- {
- m_bStarted = FALSE;
-
- CdbOleObject::SetInterfaceLic(bPrivate?CLSID_CDAOPrivDBEngine:CLSID_CDAODBEngine,dbIID_IDAODBEngine);
-
- if (pstrIniPath)
- SetIniPath(pstrIniPath);
- if (pstrDefUser)
- SetDefaultUser(pstrDefUser);
- if (pstrDefPW)
- SetDefaultPassword(pstrDefPW);
-
- if (bStart)
- Start();
-
- }
-
- CONSTRUCTOR CdbDBEngine::CdbDBEngine(
- const CdbDBEngine &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbDBEngine & CdbDBEngine::operator =(
- const CdbDBEngine &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbDBEngine::OnInterfaceChange(
- VOID)
- {
- DAODBEngine * peng = (DAODBEngine *)GetInterface();
- DAOProperties * pprps = NULL;
- DAOWorkspaces * pwrks = NULL;
- DAOErrors * perrs = NULL;
-
- if (peng && m_bStarted)
- {
- peng->get_Properties(&pprps);
- peng->get_Workspaces(&pwrks);
- peng->get_Errors(&perrs);
- }
-
- Properties.SetInterface(pprps);
- Workspaces.SetInterface(pwrks);
- Errors.SetInterface(perrs);
- }
-
- VOID CdbDBEngine::Start(
- VOID)
- {
- // If not started then start and setup collections
- if (!m_bStarted)
- {
- m_bStarted = TRUE;
- OnInterfaceChange();
- }
- }
-
- // Properties
- VOID CdbDBEngine::SetDefaultPassword(
- LPCTSTR pstr)
- {
- SPROPSET(DAODBEngine, put_DefaultPassword, pstr);
- }
-
- VOID CdbDBEngine::SetDefaultUser(
- LPCTSTR pstr)
- {
- SPROPSET(DAODBEngine, put_DefaultUser, pstr);
- }
-
- VOID CdbDBEngine::SetIniPath(
- LPCTSTR pstr)
- {
- SPROPSET(DAODBEngine, put_IniPath, pstr);
- }
-
- CString CdbDBEngine::GetIniPath(
- VOID)
- {
- SPROPGET(DAODBEngine, get_IniPath);
- }
-
- VOID CdbDBEngine::SetLoginTimeout(
- SHORT s)
- {
- WPROPSET(DAODBEngine, put_LoginTimeout, s);
- }
-
- SHORT CdbDBEngine::GetLoginTimeout(
- VOID)
- {
- WPROPGET(DAODBEngine, get_LoginTimeout);
- }
-
- CString CdbDBEngine::GetVersion(
- VOID)
- {
- SPROPGET(DAODBEngine, get_Version);
- }
-
- CString CdbDBEngine::GetSystemDB(
- VOID)
- {
- SPROPGET(DAODBEngine, get_SystemDB);
- }
-
- VOID CdbDBEngine::SetSystemDB(
- LPCTSTR pstr)
- {
- SPROPSET(DAODBEngine, put_SystemDB, pstr);
- }
-
- // Methods
- CdbWorkspace CdbDBEngine::CreateWorkspace(
- LPCTSTR pstrName,
- LPCTSTR pstrUser,
- LPCTSTR pstrPassword)
- {
- DAODBEngine * peng = (DAODBEngine *)GetInterface();
- DAOWorkspace * pwrk = NULL;
-
- if (!peng)
- return (DAOWorkspace *)NULL;
-
- DAOMFC_CALL(peng->CreateWorkspace(STB(pstrName), STB(pstrUser), STB(pstrPassword), &pwrk));
-
- return pwrk;
- }
-
- VOID CdbDBEngine::CompactDatabase(
- LPCTSTR pstrOldDatabase,
- LPCTSTR pstrNewDatabase,
- LPCTSTR pstrDstConnect, // = NULL
- LONG lOptions, // = -1
- LPCTSTR pstrSrcConnect)// = NULL
- {
- DAODBEngine * peng = (DAODBEngine *)GetInterface();
-
- DAOMFC_CALL(peng->CompactDatabase(STB(pstrOldDatabase),
- STB(pstrNewDatabase),
- STV(pstrDstConnect),
- OLTV(lOptions),
- STV(pstrSrcConnect)));
- }
-
- VOID CdbDBEngine::RepairDatabase(
- LPCTSTR pstrDatabase)
- {
- DAODBEngine * peng = (DAODBEngine *)GetInterface();
-
- DAOMFC_CALL(peng->RepairDatabase(STB(pstrDatabase)));
- }
-
- VOID CdbDBEngine::RegisterDatabase(
- LPCTSTR pstrDatabase,
- LPCTSTR pstrDriver,
- BOOL bSilent,
- LPCTSTR pstrAttributes)
- {
- DAODBEngine * peng = (DAODBEngine *)GetInterface();
-
- DAOMFC_CALL(peng->RegisterDatabase(STB(pstrDatabase), STB(pstrDriver), BTB(bSilent), STB(pstrAttributes)));
- }
-
- VOID CdbDBEngine::Idle(
- LONG lOptions) // = -1
- {
- DAODBEngine * peng = (DAODBEngine *)GetInterface();
-
- DAOMFC_CALL(peng->Idle(OLTV(lOptions)));
- }
-
- CdbDatabase CdbDBEngine::OpenDatabase(
- LPCTSTR pstrName,
- BOOL bExclusive, // = FALSE
- BOOL bReadOnly, // = FALSE
- LPCTSTR pstrConnect) // = NULL
- {
- DAODBEngine * peng = (DAODBEngine *)GetInterface();
- DAODatabase * pdb = NULL;
-
- if (!peng)
- return FALSE;
-
- DAOMFC_CALL(peng->OpenDatabase(STB(pstrName), BTV(bExclusive), BTV(bReadOnly), STV(pstrConnect), &pdb));
-
- return pdb;
- }
-
-
-
- /*****************************************************************************
- * CdbError
- */
- // Administration
- CONSTRUCTOR CdbError::CdbError(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbError::CdbError(
- DAOError * perr,
- BOOL bAddRef) // = FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)perr, bAddRef);
- }
-
- CONSTRUCTOR CdbError::CdbError(
- const CdbError &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbError & CdbError::operator =(
- const CdbError &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbError::OnInterfaceChange(
- VOID)
- {
- }
-
- // Properties
- LONG CdbError::GetNumber(
- VOID)
- {
- LPROPGET(DAOError, get_Number);
- }
-
- CString CdbError::GetSource(
- VOID)
- {
- SPROPGET(DAOError, get_Source);
- }
-
- CString CdbError::GetDescription(
- VOID)
- {
- SPROPGET(DAOError, get_Description);
- }
-
- CString CdbError::GetHelpFile(
- VOID)
- {
- SPROPGET(DAOError, get_HelpFile);
- }
-
- LONG CdbError::GetHelpContext(
- VOID)
- {
- LPROPGET(DAOError, get_HelpContext);
- }
-
- /*****************************************************************************
- * CdbWorkspace
- */
- // Administration
- CONSTRUCTOR CdbWorkspace::CdbWorkspace(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbWorkspace::CdbWorkspace(
- DAOWorkspace * pwrk,
- BOOL bAddRef) // = FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)pwrk, bAddRef);
- }
-
- CONSTRUCTOR CdbWorkspace::CdbWorkspace(
- const CdbWorkspace &o)
- {
- CdbOleObject::SetInterface(o.GetInterface(TRUE));
- }
-
- CdbWorkspace & CdbWorkspace::operator =(
- const CdbWorkspace &o)
- {
- CdbOleObject::SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbWorkspace::OnInterfaceChange(
- VOID)
- {
- DAOWorkspace * pwrk = (DAOWorkspace *)GetInterface();
- DAOProperties * pprps = NULL;
- DAOUsers * pusrs = NULL;
- DAOGroups * pgrps = NULL;
- DAODatabases * pdbs = NULL;
-
- if (pwrk)
- {
- pwrk->get_Properties(&pprps);
- pwrk->get_Databases(&pdbs);
- pwrk->get_Users(&pusrs);
- pwrk->get_Groups(&pgrps);
- }
-
- Properties.SetInterface(pprps);
- Databases.SetInterface(pdbs);
- Users.SetInterface(pusrs);
- Groups.SetInterface(pgrps);
- }
-
- // Properties
- CString CdbWorkspace::GetName(
- VOID)
- {
- SPROPGET(DAOWorkspace, get_Name);
- }
-
- VOID CdbWorkspace::SetName(
- LPCTSTR pstr)
- {
- SPROPSET(DAOWorkspace, put_Name, pstr);
- }
-
- CString CdbWorkspace::GetUserName(
- VOID)
- {
- SPROPGET(DAOWorkspace, get_UserName);
- }
-
- BOOL CdbWorkspace::GetIsolateODBCTrans(
- VOID)
- {
- BPROPGET(DAOWorkspace, get_IsolateODBCTrans);
- }
-
- VOID CdbWorkspace::SetIsolateODBCTrans(
- BOOL b)
- {
- BPROPSET(DAOWorkspace, put_IsolateODBCTrans, b);
- }
-
- // Methods
- VOID CdbWorkspace::BeginTrans(
- VOID)
- {
- DAOWorkspace * pwrk = (DAOWorkspace *)GetInterface();
-
- DAOMFC_CALL(pwrk->BeginTrans());
- }
-
- VOID CdbWorkspace::CommitTrans(
- VOID)
- {
- DAOWorkspace * pwrk = (DAOWorkspace *)GetInterface();
-
- DAOMFC_CALL(pwrk->CommitTrans());
- }
-
- VOID CdbWorkspace::Close(
- VOID)
- {
- DAOWorkspace * pwrk = (DAOWorkspace *)GetInterface();
-
- DAOMFC_CALL(pwrk->Close());
- }
-
- VOID CdbWorkspace::Rollback(
- VOID)
- {
- DAOWorkspace * pwrk = (DAOWorkspace *)GetInterface();
-
- DAOMFC_CALL(pwrk->Rollback());
- }
-
- CdbDatabase CdbWorkspace::OpenDatabase(
- LPCTSTR pstrName,
- BOOL bExclusive, // = FALSE
- BOOL bReadOnly, // = FALSE
- LPCTSTR pstrConnect) // = NULL
- {
- DAOWorkspace * pwrk = (DAOWorkspace *)GetInterface();
- DAODatabase * pdb = NULL;
-
- if (!pwrk)
- return (DAODatabase *)NULL;
-
- DAOMFC_CALL(pwrk->OpenDatabase(STB(pstrName), BTV(bExclusive), BTV(bReadOnly), STV(pstrConnect), &pdb));
-
- return pdb;
- }
-
- CdbDatabase CdbWorkspace::CreateDatabase(
- LPCTSTR pstrName,
- LPCTSTR pstrConnect,
- LONG lOption) // = -1
- {
- DAOWorkspace * pwrk = (DAOWorkspace *)GetInterface();
- DAODatabase * pdb = NULL;
-
- if (!pwrk)
- return (DAODatabase *)NULL;
-
- DAOMFC_CALL(pwrk->CreateDatabase(STB(pstrName), STB(pstrConnect), OLTV(lOption), &pdb));
-
- return pdb;
- }
-
- CdbUser CdbWorkspace::CreateUser(
- LPCTSTR pstrName, // = NULL
- LPCTSTR pstrPID, // = NULL
- LPCTSTR pstrPassword) // = NULL
- {
- DAOWorkspace * pwrk = (DAOWorkspace *)GetInterface();
- DAOUser * pusr = NULL;
-
- if (!pwrk)
- return (DAOUser *)NULL;
-
- DAOMFC_CALL(pwrk->CreateUser(STV(pstrName), STV(pstrPID), STV(pstrPassword), &pusr));
-
- return pusr;
- }
-
- CdbGroup CdbWorkspace::CreateGroup(
- LPCTSTR pstrName, // = NULL
- LPCTSTR pstrPID) // = NULL
- {
- DAOWorkspace * pwrk = (DAOWorkspace *)GetInterface();
- DAOGroup * pgrp = NULL;
-
- if (!pwrk)
- return (DAOGroup *)NULL;
-
- DAOMFC_CALL(pwrk->CreateGroup(STV(pstrName), STV(pstrPID), &pgrp));
-
- return pgrp;
- }
-
- /*****************************************************************************
- * CdbDatabase
- */
- // Administration
- CONSTRUCTOR CdbDatabase::CdbDatabase(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbDatabase::CdbDatabase(
- DAODatabase * pdb,
- BOOL bAddRef) // = FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)pdb, bAddRef);
- }
-
- CONSTRUCTOR CdbDatabase::CdbDatabase(
- const CdbDatabase &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbDatabase & CdbDatabase::operator =(
- const CdbDatabase &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbDatabase::OnInterfaceChange(
- VOID)
- {
- DAODatabase * pdb = (DAODatabase *)GetInterface();
- DAOProperties * pprps = NULL;
- DAOTableDefs * ptds = NULL;
- DAOQueryDefs * pqds = NULL;
- DAORelations * prls = NULL;
- DAOContainers * pcts = NULL;
- DAORecordsets * prss = NULL;
-
- if (pdb)
- {
- pdb->get_Properties(&pprps);
- pdb->get_TableDefs(&ptds);
- pdb->get_QueryDefs(&pqds);
- pdb->get_Relations(&prls);
- pdb->get_Containers(&pcts);
- pdb->get_Recordsets(&prss);
- }
-
- Properties.SetInterface(pprps);
- TableDefs.SetInterface(ptds);
- QueryDefs.SetInterface(pqds);
- Relations.SetInterface(prls);
- Containers.SetInterface(pcts);
- Recordsets.SetInterface(prss);
- }
-
- // Properties
- LONG CdbDatabase::GetCollatingOrder(
- VOID)
- {
- LPROPGET(DAODatabase, get_CollatingOrder);
- }
-
- CString CdbDatabase::GetConnect(
- VOID)
- {
- SPROPGET(DAODatabase, get_Connect);
- }
-
- CString CdbDatabase::GetName(
- VOID)
- {
- SPROPGET(DAODatabase, get_Name);
- }
-
- SHORT CdbDatabase::GetQueryTimeout(
- VOID)
- {
- WPROPGET(DAODatabase, get_QueryTimeout);
- }
-
- VOID CdbDatabase::SetQueryTimeout(
- SHORT s)
- {
- WPROPSET(DAODatabase, put_QueryTimeout, s);
- }
-
- BOOL CdbDatabase::GetTransactions(
- VOID)
- {
- BPROPGET(DAODatabase, get_Transactions);
- }
-
- BOOL CdbDatabase::GetUpdatable(
- VOID)
- {
- BPROPGET(DAODatabase, get_Updatable);
- }
-
- CString CdbDatabase::GetVersion(
- VOID)
- {
- SPROPGET(DAODatabase, get_Version);
- }
-
- LONG CdbDatabase::GetRecordsAffected(
- VOID)
- {
- LPROPGET(DAODatabase, get_RecordsAffected);
- }
-
- // Methods
- VOID CdbDatabase::Close(
- VOID)
- {
- DAODatabase * pdb = (DAODatabase *)GetInterface();
-
- DAOMFC_CALL(pdb->Close());
- }
-
- VOID CdbDatabase::Execute(
- LPCTSTR pstrQuery,
- LONG lOption) // = -1
- {
- DAODatabase * pdb = (DAODatabase *)GetInterface();
-
- DAOMFC_CALL(pdb->Execute(STB(pstrQuery), OLTV(lOption)));
- }
-
- CdbRecordset CdbDatabase::OpenRecordset(
- LPCTSTR pstrName,
- LONG lType, // = -1
- LONG lOptions) // = -1
- {
- DAODatabase * pdb = (DAODatabase *)GetInterface();
- DAORecordset * prs = NULL;
-
- if (!pdb)
- return (DAORecordset *)NULL;
-
- DAOMFC_CALL(pdb->OpenRecordset(STB(pstrName), OLTV(lType), OLTV(lOptions), &prs));
-
- return prs;
- }
-
- CdbProperty CdbDatabase::CreateProperty(
- LPCTSTR pstrName, // = NULL
- LONG lType, // = -1
- LPVARIANT pvValue, // = NULL
- BOOL bDDL) // = FALSE
- {
- DAODatabase * pdb = (DAODatabase *)GetInterface();
- DAOProperty * pprp = NULL;
-
- if (!pdb)
- return (DAOProperty *)NULL;
-
- DAOMFC_CALL(pdb->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
-
- return pprp;
- }
-
- CdbRelation CdbDatabase::CreateRelation(
- LPCTSTR pstrName, // = NULL
- LPCTSTR pstrTable, // = NULL
- LPCTSTR pstrForiegn, // = NULL
- LONG lAttributes) // = -1
- {
- DAODatabase * pdb = (DAODatabase *)GetInterface();
- DAORelation * prl = NULL;
-
- if (!pdb)
- return (DAORelation *)NULL;
-
- DAOMFC_CALL(pdb->CreateRelation(STV(pstrName), STV(pstrTable), STV(pstrForiegn), OLTV(lAttributes), &prl));
-
- return prl;
- }
-
- CdbTableDef CdbDatabase::CreateTableDef(
- LPCTSTR pstrName, // = NULL
- LONG lAttributes, // = -1
- LPCTSTR pstrSource, // = NULL
- LPCTSTR pstrConnect) // = NULL
- {
- DAODatabase * pdb = (DAODatabase *)GetInterface();
- DAOTableDef * ptd = NULL;
-
- if (!pdb)
- return (DAOTableDef *)NULL;
-
- DAOMFC_CALL(pdb->CreateTableDef(STV(pstrName), OLTV(lAttributes), STV(pstrSource), STV(pstrConnect), &ptd));
-
- return ptd;
- }
-
- CdbQueryDef CdbDatabase::CreateQueryDef(
- LPCTSTR pstrName, // = NULL
- LPCTSTR pstrSQL) // = NULL
- {
- DAODatabase * pdb = (DAODatabase *)GetInterface();
- DAOQueryDef * pqd = NULL;
-
- if (!pdb)
- return (DAOQueryDef *)NULL;
-
- DAOMFC_CALL(pdb->CreateQueryDef(STV(pstrName), STV(pstrSQL), &pqd));
-
- return pqd;
- }
-
- /*****************************************************************************
- * CdbRecordset
- */
- // Administration
- CONSTRUCTOR CdbRecordset::CdbRecordset(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbRecordset::CdbRecordset(
- DAORecordset * prs,
- BOOL bAddRef) // = FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)prs, bAddRef);
- }
-
- CONSTRUCTOR CdbRecordset::CdbRecordset(
- const CdbRecordset &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbRecordset & CdbRecordset::operator =(
- const CdbRecordset &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbRecordset::OnInterfaceChange(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
- DAOProperties * pprps = NULL;
- DAOFields * pflds = NULL;
- if (prs)
- {
- prs->get_Properties(&pprps);
- prs->get_Fields(&pflds);
- }
-
- Properties.SetInterface(pprps);
- Fields.SetInterface(pflds);
- }
-
- VOID CdbRecordset::SetGetRowsExInt(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
- ICDAORecordset * pGetRows = NULL;
- if (prs)
- {
- prs->QueryInterface(IID_ICDAORecordset, (void **)&pGetRows);
- }
- m_GetRowsInt.SetInterface(pGetRows);
- }
-
- // Properties
- BOOL CdbRecordset::GetBOF(
- VOID)
- {
- BPROPGET(DAORecordset, get_BOF);
- }
-
- CdbBookmark CdbRecordset::GetBookmark(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
- LPSAFEARRAY psa = NULL;
-
- if (!prs)
- return (LPSAFEARRAY)NULL;
-
- DAOMFC_CALL(prs->get_Bookmark(&psa));
-
- return psa;
- }
-
- VOID CdbRecordset::SetBookmark(
- class CdbBookmark & bm)
- {
- LPSAFEARRAY psa = (LPSAFEARRAY)bm;
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->put_Bookmark(&psa));
- }
-
- BOOL CdbRecordset::GetBookmarkable(
- VOID)
- {
- BPROPGET(DAORecordset, get_Bookmarkable);
- }
-
- COleDateTime CdbRecordset::GetDateCreated(
- VOID)
- {
- DPROPGET(DAORecordset, get_DateCreated);
- }
-
- COleDateTime CdbRecordset::GetLastUpdated(
- VOID)
- {
- DPROPGET(DAORecordset, get_LastUpdated);
- }
-
- BOOL CdbRecordset::GetEOF(
- VOID)
- {
- BPROPGET(DAORecordset, get_EOF);
- }
-
- CString CdbRecordset::GetFilter(
- VOID)
- {
- SPROPGET(DAORecordset, get_Filter);
- }
-
- VOID CdbRecordset::SetFilter(
- LPCTSTR pstr)
- {
- SPROPSET(DAORecordset, put_Filter, pstr);
- }
-
- CString CdbRecordset::GetIndex(
- VOID)
- {
- SPROPGET(DAORecordset, get_Index);
- }
-
- VOID CdbRecordset::SetIndex(
- LPCTSTR pstr)
- {
- SPROPSET(DAORecordset, put_Index, pstr);
- }
-
- CdbBookmark CdbRecordset::GetLastModified(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
- LPSAFEARRAY psa;
-
- if (!prs)
- return (LPSAFEARRAY)NULL;
-
- DAOMFC_CALL(prs->get_LastModified(&psa));
-
- return psa;
- }
-
- BOOL CdbRecordset::GetLockEdits(
- VOID)
- {
- BPROPGET(DAORecordset, get_LockEdits);
- }
-
- VOID CdbRecordset::SetLockEdits(
- BOOL b)
- {
- BPROPSET(DAORecordset, put_LockEdits, b);
- }
-
- CString CdbRecordset::GetName(
- VOID)
- {
- SPROPGET(DAORecordset, get_Name);
- }
-
- BOOL CdbRecordset::GetNoMatch(
- VOID)
- {
- BPROPGET(DAORecordset, get_NoMatch);
- }
-
- CString CdbRecordset::GetSort(
- VOID)
- {
- SPROPGET(DAORecordset, get_Sort);
- }
-
- VOID CdbRecordset::SetSort(
- LPCTSTR pstr)
- {
- SPROPSET(DAORecordset, put_Sort, pstr);
- }
-
- BOOL CdbRecordset::GetTransactions(
- VOID)
- {
- BPROPGET(DAORecordset, get_Transactions);
- }
-
- SHORT CdbRecordset::GetType(
- VOID)
- {
- WPROPGET(DAORecordset, get_Type);
- }
-
- LONG CdbRecordset::GetRecordCount(
- VOID)
- {
- LPROPGET(DAORecordset, get_RecordCount);
- }
-
- BOOL CdbRecordset::GetUpdatable(
- VOID)
- {
- BPROPGET(DAORecordset, get_Updatable);
- }
-
- BOOL CdbRecordset::GetRestartable(
- VOID)
- {
- BPROPGET(DAORecordset, get_Restartable);
- }
-
- CString CdbRecordset::GetValidationText(
- VOID)
- {
- SPROPGET(DAORecordset, get_ValidationText);
- }
-
- CString CdbRecordset::GetValidationRule(
- VOID)
- {
- SPROPGET(DAORecordset, get_ValidationRule);
- }
-
- CdbBookmark CdbRecordset::GetCacheStart(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
- LPSAFEARRAY psa;
-
- if (!prs)
- return (LPSAFEARRAY)NULL;
-
- DAOMFC_CALL(prs->get_CacheStart(&psa));
-
- return psa;
- }
-
- VOID CdbRecordset::SetCacheStart(
- CdbBookmark &bm)
- {
- LPSAFEARRAY psa = (LPSAFEARRAY)bm;
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->put_CacheStart(&psa));
- }
-
- LONG CdbRecordset::GetCacheSize(
- VOID)
- {
- LPROPGET(DAORecordset, get_CacheSize);
- }
-
- VOID CdbRecordset::SetCacheSize(
- LONG l)
- {
- LPROPSET(DAORecordset, put_CacheSize, l);
- }
-
- FLOAT CdbRecordset::GetPercentPosition(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
- FLOAT f = (FLOAT)0.0;
-
- if (!prs)
- return (FLOAT)0.0;
-
- DAOMFC_CALL(prs->get_PercentPosition(&f));
-
- return f;
- }
-
- VOID CdbRecordset::SetPercentPosition(
- FLOAT f)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->put_PercentPosition(f));
- }
-
- LONG CdbRecordset::GetAbsolutePosition(
- VOID)
- {
- LPROPGET(DAORecordset, get_AbsolutePosition);
- }
-
- VOID CdbRecordset::SetAbsolutePosition(
- LONG l)
- {
- LPROPSET(DAORecordset, put_AbsolutePosition, l);
- }
-
- SHORT CdbRecordset::GetEditMode(
- VOID)
- {
- WPROPGET(DAORecordset, get_EditMode);
- }
-
- // Methods
- VOID CdbRecordset::CancelUpdate(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->CancelUpdate());
- }
-
- VOID CdbRecordset::AddNew(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->AddNew());
- }
-
- VOID CdbRecordset::Close(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->Close());
- }
-
- CdbRecordset CdbRecordset::OpenRecordset(
- LONG lType, // = -1
- LONG lOption) // = -1
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
- DAORecordset * prsNew = NULL;
-
- if (!prs)
- return (DAORecordset *)NULL;
-
- DAOMFC_CALL(prs->OpenRecordset(SHTV(lType), OLTV(lOption), &prsNew));
-
- return prsNew;
- }
-
- VOID CdbRecordset::Delete(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->Delete());
- }
-
- VOID CdbRecordset::Edit(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->Edit());
- }
-
- VOID CdbRecordset::FindFirst(
- LPCTSTR pstrCriteria)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->FindFirst(STB(pstrCriteria)));
- }
-
- VOID CdbRecordset::FindLast(
- LPCTSTR pstrCriteria)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->FindLast(STB(pstrCriteria)));
- }
-
- VOID CdbRecordset::FindNext(
- LPCTSTR pstrCriteria)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->FindNext(STB(pstrCriteria)));
- }
-
- VOID CdbRecordset::FindPrevious(
- LPCTSTR pstrCriteria)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->FindPrevious(STB(pstrCriteria)));
- }
-
- VOID CdbRecordset::MoveFirst(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->MoveFirst());
- }
-
- VOID CdbRecordset::MoveLast(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->MoveLast());
- }
-
- VOID CdbRecordset::MoveNext(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->MoveNext());
- }
-
- VOID CdbRecordset::MovePrevious(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->MovePrevious());
- }
-
-
- VOID CdbRecordset::Seek(
- LPCTSTR pstrComparison,
- LONG lNumFields,
- COleVariant cKey,
- ...)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
- COleVariant * lpV;
- va_list valist;
- CdbVariant v[13];
- LONG lIndex;
-
- ASSERT(lNumFields <= DAO_MAXSEEKFIELDS && lNumFields > 0);
-
- lpV = &cKey;
- va_start(valist, cKey);
-
- v[0] = *lpV;
- for(lIndex = 1; lIndex < lNumFields && (lpV = &(va_arg(valist, COleVariant))) != 0; lIndex++ )
- {
- v[lIndex] = *lpV;
- }
-
- va_end(valist);
-
- 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]));
- }
-
- VOID CdbRecordset::Update(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- DAOMFC_CALL(prs->Update());
- }
-
- CdbRecordset CdbRecordset::Clone(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
- DAORecordset * prsNew = NULL;
-
- if (!prs)
- return FALSE;
-
- DAOMFC_CALL(prs->Clone(&prsNew));
-
- return prsNew;
- }
-
- VOID CdbRecordset::Requery(
- CdbQueryDef *pq) // = NULL
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
- COleVariant Var;
-
- //Manually load the Query Def as a dispatch
- if (!pq)
- {
- Var.vt = VT_ERROR;
- Var.scode = DISP_E_PARAMNOTFOUND;
- }
- else
- {
- Var.vt = VT_DISPATCH;
- Var.pdispVal = (LPDISPATCH)pq->GetInterface();
- }
-
- DAOMFC_CALL(prs->Requery(Var));
- }
-
- VOID CdbRecordset::Move(
- LONG lRows,
- CdbBookmark *pbm) // = NULL
- {
- LPSAFEARRAY psa = NULL;
- COleVariant Var;
-
- if(pbm)
- {
- psa = (LPSAFEARRAY)(*pbm);
- }
-
- DAORecordset * prs = (DAORecordset *)GetInterface();
-
- //Load the safe array into the COleVariant
- ATV(psa, Var);
-
- DAOMFC_CALL(prs->Move(lRows, Var));
- }
-
- VOID CdbRecordset::FillCache(
- LONG lRows, // = -1
- CdbBookmark * pbm) // = NULL
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
- COleVariant Var;
-
- //Load the safe array into the COleVariant
- ATV((LPSAFEARRAY)pbm, Var);
-
- DAOMFC_CALL(prs->FillCache(OLTV(lRows), Var));
- }
-
- CdbQueryDef CdbRecordset::CopyQueryDef(
- VOID)
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
- DAOQueryDef * pqd = NULL;
-
- if (!prs)
- return (DAOQueryDef *)NULL;
-
- DAOMFC_CALL(prs->CopyQueryDef(&pqd));
-
- return pqd;
- }
-
- COleVariant CdbRecordset::GetRows(
- LONG lRows) // = -1
- {
- DAORecordset * prs = (DAORecordset *)GetInterface();
- VARIANT v;
-
- if (!prs)
- return (LPVARIANT)NULL;
-
- VariantInit(&v);
- DAOMFC_CALL(prs->GetRows(OLTV(lRows), &v));
-
- return &v;
- }
-
- LONG CdbRecordset::GetRowsEx(
- LPVOID pvBuffer,
- LONG cbRow,
- LPDAORSETBINDING prb,
- LONG cBinding,
- LPVOID pvVarBuffer, //= NULL
- LONG cbVarBuffer, // = 0
- LONG lRows) // = -1
- {
- ICDAORecordset * prs;
- DAOFETCHROWS fetch;
- HRESULT hresult;
-
- ASSERT(cBinding > 0);
- ASSERT(prb != 0);
-
- //Clear flags
- fetch.dwFlags = 0;
-
- //The GetRowsEx interface isn't set until the first time this function
- //is called
- if(!m_GetRowsInt.Exists())
- SetGetRowsExInt();
-
- prs = (ICDAORecordset *)m_GetRowsInt.GetInterface();
-
- if (!prs)
- return 0L;
-
- LPDAOCOLUMNBINDING pColumnBind = new DAOCOLUMNBINDING [cBinding];
-
- for(LONG iBinding=0;iBinding<cBinding;iBinding++)
- {
- if(prb[iBinding].dwBindIndexType == dbBindIndexINT)
- {
- pColumnBind[iBinding].columnID.dwKind = DAOCOLKIND_IND;
- pColumnBind[iBinding].columnID.ind = prb[iBinding].i;
- }
- else
- {
- #ifdef _UNICODE
- pColumnBind[iBinding].columnID.dwKind = DAOCOLKIND_WSTR;
- pColumnBind[iBinding].columnID.lpwstr = prb[iBinding].pstr;
- #else
- pColumnBind[iBinding].columnID.dwKind = DAOCOLKIND_STR;
- pColumnBind[iBinding].columnID.lpstr = prb[iBinding].pstr;
- #endif
-
- }
- pColumnBind[iBinding].cbDataOffset = prb[iBinding].dwOffset;
- pColumnBind[iBinding].cbMaxLen = prb[iBinding].cb;
- pColumnBind[iBinding].cbInfoOffset = DAO_NOINDICATOR;
-
- //Variants bound differently
- if(prb[iBinding].dwType != dbBindVARIANT)
- {
- pColumnBind[iBinding].dwBinding = DAOBINDING_DIRECT;
- }
- else
- {
- pColumnBind[iBinding].dwBinding = DAOBINDING_VARIANT;
- }
- pColumnBind[iBinding].dwDataType = prb[iBinding].dwType;
- pColumnBind[iBinding].dwUser = 0; }
-
- fetch.cRowsRequested = lRows;
- fetch.pData = pvBuffer;
- fetch.pVarData = pvVarBuffer;
- fetch.cbVarData = cbVarBuffer;
-
- hresult = prs->GetRows(0, cBinding, (LPDAOCOLUMNBINDING)&pColumnBind[0], cbRow, (LPDAOFETCHROWS)&fetch);
-
- delete [] pColumnBind;
-
- /* There are error text strings in DBDAOx(u).dll in a string table for GetRowsEx
- which are currently disabled. They will show up alongside the published DAO
- errors in a later release
-
- //Check return code
- #if !defined(DAOMFC_DONT_THROW_EXCEPTIONS)
- LONG lstrID;
- switch (GetScode(hresult))
- {
- case S_BUFFERTOOSMALL :
- lstrID = IDS_BUFFERTOOSMALL;
- break;
-
- case S_ENDOFCURSOR:
- lstrID = IDS_ENDOFCURSOR;
- break;
-
- case S_SILENTCANCEL:
- lstrID = IDS_SILENTCANCEL;
- break;
-
- case S_RECORDDELETED:
- lstrID = IDS_RECORDDELETED;
- break;
-
- case E_ROWTOOSHORT:
- lstrID = IDS_ROWTOOSHORT;
- break;
-
- case E_BADBINDINFO:
- lstrID = IDS_BADBINDINFO;
- break;
-
- case E_COLUMNUNAVAILABLE:
- lstrID = IDS_COLUMNUNAVAILABLE;
- break;
-
- default:
- lstrID = 0L;
- }
-
- if(lstrID)
- {
- CString strErr;
- BSTR bstrVal;
- strErr.LoadString(lstrID);
- #ifdef UNICODE
- bstrVal = SysAllocString(strErr);
- #else
- bstrVal = SysAllocStringByteLen(strErr, strlen(strErr));
- #endif
- SetRichErrorInfo(L"DBDAO", bstrVal, NULL, 0L);
-
- SysFreeString(bstrVal);
- }
- */
- #if !defined(DAOMFC_DONT_THROW_EXCEPTIONS)
- if(FAILED(hresult))
- {
- TRACE0("\nGetRowsEX Call Failed.\n\t");
- TRACE2("\nIn file %s on line %d\n", THIS_FILE, __LINE__);
- TRACE1("hResult = %X\n", hresult);
- if (GetScode(hresult) == E_OUTOFMEMORY)
- {
- AfxThrowMemoryException();
- }
- else
- {
- throw CdbException(hresult);
- }
-
- }
- #endif
- return fetch.cRowsReturned;
- }
-
- COleVariant CdbRecordset::GetField(
- LPCTSTR pstrIndex)
- {
- COleVariant vValue;
-
- GetFieldV(STV(pstrIndex), vValue);
-
- return vValue;
- }
-
- COleVariant CdbRecordset::GetField(
- LONG lIndex)
- {
- COleVariant vValue;
-
- GetFieldV(LTV(lIndex), vValue);
-
- return vValue;
- }
-
-
- VOID CdbRecordset::SetField(
- LPCTSTR pstrIndex,
- LPVARIANT pv)
- {
- SetFieldV(STV(pstrIndex), pv);
- }
-
- VOID CdbRecordset::SetField(
- LONG lIndex,
- LPVARIANT pv)
- {
- SetFieldV(LTV(lIndex), pv);
- }
-
-
- /*****************************************************************************
- * CdbGetRowsEx
- */
- // Administration
- CONSTRUCTOR CdbGetRowsEx::CdbGetRowsEx(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbGetRowsEx::CdbGetRowsEx(
- ICDAORecordset * pGetRows,
- BOOL bAddRef) // = FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)pGetRows, bAddRef);
- }
-
- CONSTRUCTOR CdbGetRowsEx::CdbGetRowsEx(
- const CdbGetRowsEx &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbGetRowsEx & CdbGetRowsEx::operator =(
- const CdbGetRowsEx &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
-
- VOID CdbGetRowsEx::OnInterfaceChange(
- VOID)
- {
- ICDAORecordset * pGetRows = (ICDAORecordset *)GetInterface();
-
- }
-
-
- /*****************************************************************************
- * CdbField
- */
- // Administration
- CONSTRUCTOR CdbField::CdbField(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbField::CdbField(
- DAOField * pfld,
- BOOL bAddRef) // = FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)pfld, bAddRef);
- }
-
- CONSTRUCTOR CdbField::CdbField(
- const CdbField &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbField & CdbField::operator =(
- const CdbField &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbField::OnInterfaceChange(
- VOID)
- {
- DAOField * pfld = (DAOField *)GetInterface();
- DAOProperties * pprps = NULL;
-
- if (pfld)
- {
- pfld->get_Properties(&pprps);
- }
-
- Properties.SetInterface(pprps);
- }
-
- // Properties
- LONG CdbField::GetCollatingOrder(
- VOID)
- {
- LPROPGET(DAOField, get_CollatingOrder);
- }
-
- SHORT CdbField::GetType(
- VOID)
- {
- WPROPGET(DAOField, get_Type);
- }
-
- VOID CdbField::SetType(
- SHORT s)
- {
- WPROPSET(DAOField, put_Type, s);
- }
-
- CString CdbField::GetName(
- VOID)
- {
- SPROPGET(DAOField, get_Name);
- }
-
- VOID CdbField::SetName(
- LPCTSTR pstr)
- {
- SPROPSET(DAOField, put_Name, pstr);
- }
-
- LONG CdbField::GetSize(
- VOID)
- {
- LPROPGET(DAOField, get_Size);
- }
-
- VOID CdbField::SetSize(
- LONG l)
- {
- LPROPSET(DAOField, put_Size, l);
- }
-
- CString CdbField::GetSourceField(
- VOID)
- {
- SPROPGET(DAOField, get_SourceField);
- }
-
- CString CdbField::GetSourceTable(
- VOID)
- {
- SPROPGET(DAOField, get_SourceTable);
- }
-
- COleVariant CdbField::GetValue(
- VOID)
- {
- VPROPGET(DAOField, get_Value);
- }
-
-
- VOID CdbField::SetValue(
- LPVARIANT pv)
- {
- VPROPSET(DAOField, put_Value, pv);
- }
-
- LONG CdbField::GetAttributes(
- VOID)
- {
- LPROPGET(DAOField, get_Attributes);
- }
-
- VOID CdbField::SetAttributes(
- LONG l)
- {
- LPROPSET(DAOField, put_Attributes, l);
- }
-
- SHORT CdbField::GetOrdinalPosition(
- VOID)
- {
- WPROPGET(DAOField, get_OrdinalPosition);
- }
-
- VOID CdbField::SetOrdinalPosition(
- SHORT s)
- {
- WPROPSET(DAOField, put_OrdinalPosition, s);
- }
-
- CString CdbField::GetValidationText(
- VOID)
- {
- SPROPGET(DAOField, get_ValidationText);
- }
-
- VOID CdbField::SetValidationText(
- LPCTSTR pstr)
- {
- SPROPSET(DAOField, put_ValidationText, pstr);
- }
-
- BOOL CdbField::GetValidateOnSet(
- VOID)
- {
- BPROPGET(DAOField, get_ValidateOnSet);
- }
-
- VOID CdbField::SetValidateOnSet(
- BOOL b)
- {
- BPROPSET(DAOField, put_ValidateOnSet, b);
- }
-
- CString CdbField::GetValidationRule(
- VOID)
- {
- SPROPGET(DAOField, get_ValidationRule);
- }
-
- VOID CdbField::SetValidationRule(
- LPCTSTR pstr)
- {
- SPROPSET(DAOField, put_ValidationRule, pstr);
- }
-
- CString CdbField::GetDefaultValue(
- VOID)
- {
- SPROPGET(DAOField, get_DefaultValue);
- }
-
- VOID CdbField::SetDefaultValue(
- LPCTSTR pstr)
- {
- SPROPSET(DAOField, put_DefaultValue, pstr);
- }
-
- BOOL CdbField::GetRequired(
- VOID)
- {
- BPROPGET(DAOField, get_Required);
- }
-
- VOID CdbField::SetRequired(
- BOOL b)
- {
- BPROPSET(DAOField, put_Required, b);
- }
-
- BOOL CdbField::GetAllowZeroLength(
- VOID)
- {
- BPROPGET(DAOField, get_AllowZeroLength);
- }
-
- VOID CdbField::SetAllowZeroLength(
- BOOL b)
- {
- BPROPSET(DAOField, put_AllowZeroLength, b);
- }
-
- BOOL CdbField::GetDataUpdatable(
- VOID)
- {
- BPROPGET(DAOField, get_DataUpdatable);
- }
-
- CString CdbField::GetForeignName(
- VOID)
- {
- SPROPGET(DAOField, get_ForeignName);
- }
-
- VOID CdbField::SetForeignName(
- LPCTSTR pstr)
- {
- SPROPSET(DAOField, put_ForeignName, pstr);
- }
-
- // Methods
- VOID CdbField::AppendChunk(
- LPVARIANT pv)
- {
- DAOField * pfld = (DAOField *)GetInterface();
-
- DAOMFC_CALL(pfld->AppendChunk(*pv));
- }
-
- COleVariant CdbField::GetChunk(
- LONG lOffset,
- LONG lBytes)
- {
- DAOField * pfld = (DAOField *)GetInterface();
- COleVariant v;
-
- if (!pfld)
- return (LPVARIANT)NULL;
-
- VariantInit(&v);
- DAOMFC_CALL(pfld->GetChunk(lOffset, lBytes, &v));
-
- return &v;
- }
-
- LONG CdbField::FieldSize(
- VOID)
- {
- DAOField * pfld = (DAOField *)GetInterface();
- LONG l = 0;
-
- if (!pfld)
- return 0;
-
- DAOMFC_CALL(pfld->FieldSize(&l));
-
- return l;
- }
-
- CdbProperty CdbField::CreateProperty(
- LPCTSTR pstrName, // = NULL
- LONG lType, // = -1
- LPVARIANT pvValue, // = NULL
- BOOL bDDL) // = FALSE
- {
- DAOField * pfld = (DAOField *)GetInterface();
- DAOProperty * pprp = NULL;
-
- if (!pfld)
- return (DAOProperty *)NULL;
-
- DAOMFC_CALL(pfld->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
-
- return pprp;
- }
-
- /*****************************************************************************
- * CdbQueryDef
- */
- // Administration
- CONSTRUCTOR CdbQueryDef::CdbQueryDef(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbQueryDef::CdbQueryDef(
- DAOQueryDef * pqd,
- BOOL bAddRef) // FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)pqd, bAddRef);
- }
-
- CONSTRUCTOR CdbQueryDef::CdbQueryDef(
- const CdbQueryDef &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbQueryDef & CdbQueryDef::operator =(
- const CdbQueryDef &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbQueryDef::OnInterfaceChange(
- VOID)
- {
- DAOQueryDef * pqd = (DAOQueryDef *)GetInterface();
- DAOProperties * pprps = NULL;
- DAOFields * pflds = NULL;
- DAOParameters * pprms = NULL;
-
- if (pqd)
- {
- pqd->get_Properties(&pprps);
- pqd->get_Fields(&pflds);
- pqd->get_Parameters(&pprms);
- }
-
- Properties.SetInterface(pprps);
- Fields.SetInterface(pflds);
- Parameters.SetInterface(pprms);
- }
-
- // Properties
- COleDateTime CdbQueryDef::GetDateCreated(
- VOID)
- {
- DPROPGET(DAOQueryDef, get_DateCreated);
- }
-
- COleDateTime CdbQueryDef::GetLastUpdated(
- VOID)
- {
- DPROPGET(DAOQueryDef, get_LastUpdated);
- }
-
- CString CdbQueryDef::GetName(
- VOID)
- {
- SPROPGET(DAOQueryDef, get_Name);
- }
-
- VOID CdbQueryDef::SetName(
- LPCTSTR pstr)
- {
- SPROPSET(DAOQueryDef, put_Name, pstr);
- }
-
- SHORT CdbQueryDef::GetODBCTimeout(
- VOID)
- {
- WPROPGET(DAOQueryDef, get_ODBCTimeout);
- }
-
- VOID CdbQueryDef::SetODBCTimeout(
- SHORT s)
- {
- WPROPSET(DAOQueryDef, put_ODBCTimeout, s);
- }
-
- SHORT CdbQueryDef::GetType(
- VOID)
- {
- WPROPGET(DAOQueryDef, get_Type);
- }
-
- CString CdbQueryDef::GetSQL(
- VOID)
- {
- SPROPGET(DAOQueryDef, get_SQL);
- }
-
- VOID CdbQueryDef::SetSQL(
- LPCTSTR pstr)
- {
- SPROPSET(DAOQueryDef, put_SQL, pstr);
- }
-
- BOOL CdbQueryDef::GetUpdatable(
- VOID)
- {
- BPROPGET(DAOQueryDef, get_Updatable);
- }
-
- CString CdbQueryDef::GetConnect(
- VOID)
- {
- SPROPGET(DAOQueryDef, get_Connect);
- }
-
- VOID CdbQueryDef::SetConnect(
- LPCTSTR pstr)
- {
- SPROPSET(DAOQueryDef, put_Connect, pstr);
- }
-
- BOOL CdbQueryDef::GetReturnsRecords(
- VOID)
- {
- BPROPGET(DAOQueryDef, get_ReturnsRecords);
- }
-
- VOID CdbQueryDef::SetReturnsRecords(
- BOOL b)
- {
- BPROPSET(DAOQueryDef, put_ReturnsRecords, b);
- }
-
- LONG CdbQueryDef::GetRecordsAffected(
- VOID)
- {
- LPROPGET(DAOQueryDef, get_RecordsAffected);
- }
-
- // Methods
- CdbRecordset CdbQueryDef::OpenRecordset(
- LONG lType, // = -1
- LONG lOption) // = -1
- {
- DAOQueryDef * pqd = (DAOQueryDef *)GetInterface();
- DAORecordset * prs = NULL;
-
- if (!pqd)
- return (DAORecordset *)NULL;
-
- DAOMFC_CALL(pqd->OpenRecordset(OLTV(lType), OLTV(lOption), &prs));
-
- return prs;
- }
-
- VOID CdbQueryDef::Execute(
- LONG lOption) // = -1
- {
- DAOQueryDef * pqd = (DAOQueryDef *)GetInterface();
-
- DAOMFC_CALL(pqd->Execute(OLTV(lOption)));
- }
-
- CdbProperty CdbQueryDef::CreateProperty(
- LPCTSTR pstrName, // = NULL
- LONG lType, // = -1
- LPVARIANT pvValue, // = NULL
- BOOL bDDL) // = FALSE
- {
- DAOQueryDef * pqd = (DAOQueryDef *)GetInterface();
- DAOProperty * pprp = NULL;
-
- if (!pqd)
- return (DAOProperty *)NULL;
-
- DAOMFC_CALL(pqd->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
-
- return pprp;
- }
-
- /*****************************************************************************
- * CdbTableDef
- */
- // Administration
- CONSTRUCTOR CdbTableDef::CdbTableDef(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbTableDef::CdbTableDef(
- DAOTableDef * ptd,
- BOOL bAddRef) // = FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)ptd, bAddRef);
- }
-
- CONSTRUCTOR CdbTableDef::CdbTableDef(
- const CdbTableDef &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbTableDef & CdbTableDef::operator =(
- const CdbTableDef &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbTableDef::OnInterfaceChange(
- VOID)
- {
- DAOTableDef * ptd = (DAOTableDef *)GetInterface();
- DAOProperties * pprps = NULL;
- DAOFields * pflds = NULL;
- DAOIndexes * pidxs = NULL;
-
- if (ptd)
- {
- ptd->get_Properties(&pprps);
- ptd->get_Fields(&pflds);
- ptd->get_Indexes(&pidxs);
- }
-
- Properties.SetInterface(pprps);
- Fields.SetInterface(pflds);
- Indexes.SetInterface(pidxs);
- }
-
- // Properties
- LONG CdbTableDef::GetAttributes(
- VOID)
- {
- LPROPGET(DAOTableDef, get_Attributes);
- }
-
- VOID CdbTableDef::SetAttributes(
- LONG l)
- {
- LPROPSET(DAOTableDef, put_Attributes, l);
- }
-
- CString CdbTableDef::GetConnect(
- VOID)
- {
- SPROPGET(DAOTableDef, get_Connect);
- }
-
- VOID CdbTableDef::SetConnect(
- LPCTSTR pstr)
- {
- SPROPSET(DAOTableDef, put_Connect, pstr);
- }
-
- COleDateTime CdbTableDef::GetDateCreated(
- VOID)
- {
- DPROPGET(DAOTableDef, get_DateCreated);
- }
-
- COleDateTime CdbTableDef::GetLastUpdated(
- VOID)
- {
- DPROPGET(DAOTableDef, get_LastUpdated);
- }
-
- CString CdbTableDef::GetName(
- VOID)
- {
- SPROPGET(DAOTableDef, get_Name);
- }
-
- VOID CdbTableDef::SetName(
- LPCTSTR pstr)
- {
- SPROPSET(DAOTableDef, put_Name, pstr);
- }
-
- CString CdbTableDef::GetSourceTableName(
- VOID)
- {
- SPROPGET(DAOTableDef, get_SourceTableName);
- }
-
- VOID CdbTableDef::SetSourceTableName(
- LPCTSTR pstr)
- {
- SPROPSET(DAOTableDef, put_SourceTableName, pstr);
- }
-
- BOOL CdbTableDef::GetUpdatable(
- VOID)
- {
- BPROPGET(DAOTableDef, get_Updatable);
- }
-
- CString CdbTableDef::GetValidationText(
- VOID)
- {
- SPROPGET(DAOTableDef, get_ValidationText);
- }
-
- VOID CdbTableDef::SetValidationText(
- LPCTSTR pstr)
- {
- SPROPSET(DAOTableDef, put_ValidationText, pstr);
- }
-
- CString CdbTableDef::GetValidationRule(
- VOID)
- {
- SPROPGET(DAOTableDef, get_ValidationRule);
- }
-
- VOID CdbTableDef::SetValidationRule(
- LPCTSTR pstr)
- {
- SPROPSET(DAOTableDef, put_ValidationRule, pstr);
- }
-
- LONG CdbTableDef::GetRecordCount(
- VOID)
- {
- LPROPGET(DAOTableDef, get_RecordCount);
- }
-
- // Methods
- CdbRecordset CdbTableDef::OpenRecordset(
- LONG lType, // = -1
- LONG lOption) // = -1
- {
- DAOTableDef * ptd = (DAOTableDef *)GetInterface();
- DAORecordset * prs = NULL;
-
- if (!ptd)
- return (DAORecordset *)NULL;
-
- DAOMFC_CALL(ptd->OpenRecordset(OLTV(lType), OLTV(lOption), &prs));
-
- return prs;
- }
-
- VOID CdbTableDef::RefreshLink(
- VOID)
- {
- DAOTableDef * ptd = (DAOTableDef *)GetInterface();
-
- DAOMFC_CALL(ptd->RefreshLink());
- }
-
- CdbField CdbTableDef::CreateField(
- LPCTSTR pstrName, // = NULL
- LONG lType, // = -1
- LONG lSize) // = -1
- {
- DAOTableDef * ptd = (DAOTableDef *)GetInterface();
- DAOField * pfld = NULL;
-
- if (!ptd)
- return (DAOField *)NULL;
-
- DAOMFC_CALL(ptd->CreateField(STV(pstrName), OLTV(lType), OLTV(lSize), &pfld));
-
- return pfld;
- }
-
- CdbIndex CdbTableDef::CreateIndex(
- LPCTSTR pstrName) // = NULL
- {
- DAOTableDef * ptd = (DAOTableDef *)GetInterface();
- DAOIndex * pidx = NULL;
-
- if (!ptd)
- return (DAOIndex *)NULL;
-
- DAOMFC_CALL(ptd->CreateIndex(STV(pstrName), &pidx));
-
- return pidx;
- }
-
- CdbProperty CdbTableDef::CreateProperty(
- LPCTSTR pstrName, // = NULL
- LONG lType, // = -1
- LPVARIANT pvValue, // = NULL
- BOOL bDDL) // = FALSE
- {
- DAOTableDef * ptd = (DAOTableDef *)GetInterface();
- DAOProperty * pprp = NULL;
-
- if (!ptd)
- return (DAOProperty *)NULL;
-
- DAOMFC_CALL(ptd->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
-
- return pprp;
- }
-
- /*****************************************************************************
- * CdbIndex
- */
- // Administration
- CONSTRUCTOR CdbIndex::CdbIndex(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbIndex::CdbIndex(
- DAOIndex * pidx,
- BOOL bAddRef) // = FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)pidx, bAddRef);
- }
-
- CONSTRUCTOR CdbIndex::CdbIndex(
- const CdbIndex &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbIndex & CdbIndex::operator =(
- const CdbIndex &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbIndex::OnInterfaceChange(
- VOID)
- {
- DAOIndex * pidx = (DAOIndex *)GetInterface();
- DAOProperties * pprps = NULL;
- DAOFields * pflds = NULL;
-
- if (pidx)
- {
- VARIANT v;
-
- VariantInit(&v);
-
- pidx->get_Properties(&pprps);
- pidx->get_Fields(&v);
-
- v.pdispVal->QueryInterface(dbIID_IDAOIndexFields, (LPVOID *)&pflds);
- v.pdispVal->Release();
- }
-
- Properties.SetInterface(pprps);
- Fields.SetInterface(pflds);
- }
-
- // Properties
- CString CdbIndex::GetName(
- VOID)
- {
- SPROPGET(DAOIndex, get_Name);
- }
-
- VOID CdbIndex::SetName(
- LPCTSTR pstr)
- {
- SPROPSET(DAOIndex, put_Name, pstr);
- }
-
- BOOL CdbIndex::GetForeign(
- VOID)
- {
- BPROPGET(DAOIndex, get_Foreign);
- }
-
- BOOL CdbIndex::GetUnique(
- VOID)
- {
- BPROPGET(DAOIndex, get_Unique);
- }
-
- VOID CdbIndex::SetUnique(
- BOOL b)
- {
- BPROPSET(DAOIndex, put_Unique, b);
- }
-
- BOOL CdbIndex::GetClustered(
- VOID)
- {
- BPROPGET(DAOIndex, get_Clustered);
- }
-
- VOID CdbIndex::SetClustered(
- BOOL b)
- {
- BPROPSET(DAOIndex, put_Clustered, b);
- }
-
- BOOL CdbIndex::GetRequired(
- VOID)
- {
- BPROPGET(DAOIndex, get_Required);
- }
-
- VOID CdbIndex::SetRequired(
- BOOL b)
- {
- BPROPSET(DAOIndex, put_Required, b);
- }
-
- BOOL CdbIndex::GetIgnoreNulls(
- VOID)
- {
- BPROPGET(DAOIndex, get_IgnoreNulls);
- }
-
- VOID CdbIndex::SetIgnoreNulls(
- BOOL b)
- {
- BPROPSET(DAOIndex, put_IgnoreNulls, b);
- }
-
- BOOL CdbIndex::GetPrimary(
- VOID)
- {
- BPROPGET(DAOIndex, get_Primary);
- }
-
- VOID CdbIndex::SetPrimary(
- BOOL b)
- {
- BPROPSET(DAOIndex, put_Primary, b);
- }
-
- LONG CdbIndex::GetDistinctCount(
- VOID)
- {
- LPROPGET(DAOIndex, get_DistinctCount);
- }
-
-
- // Methods
- CdbField CdbIndex::CreateField(
- LPCTSTR pstrName, // = NULL
- LONG lType, // = -1
- LONG lSize) // = -1
- {
- DAOIndex * pidx = (DAOIndex *)GetInterface();
- DAOField * pfld = NULL;
-
- if (!pidx)
- return (DAOField *)NULL;
-
- DAOMFC_CALL(pidx->CreateField(STV(pstrName), OLTV(lType), OLTV(lSize), &pfld));
-
- return pfld;
- }
-
- CdbProperty CdbIndex::CreateProperty(
- LPCTSTR pstrName, // = NULL
- LONG lType, // = -1
- LPVARIANT pvValue, // = NULL
- BOOL bDDL) // = FALSE
- {
- DAOIndex * pidx = (DAOIndex *)GetInterface();
- DAOProperty * pprp = NULL;
-
- if (!pidx)
- return (DAOProperty *)NULL;
-
- DAOMFC_CALL(pidx->CreateProperty(STV(pstrName), OLTV(lType), VTV(pvValue), BTV(bDDL), &pprp));
-
- return pprp;
- }
-
-
- /*****************************************************************************
- * CdbProperty
- */
- // Administration
- CONSTRUCTOR CdbProperty::CdbProperty(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbProperty::CdbProperty(
- DAOProperty * pprp,
- BOOL bAddRef) // = FALSE
- {
- SetInterface((LPUNKNOWN)pprp, bAddRef);
- }
-
- CONSTRUCTOR CdbProperty::CdbProperty(
- const CdbProperty &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbProperty & CdbProperty::operator =(
- const CdbProperty &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- // Properties
- COleVariant CdbProperty::GetValue(
- VOID)
- {
- DAOProperty * pprp = (DAOProperty *)GetInterface();
- COleVariant v;
-
- if (!pprp)
- return v;
-
- DAOMFC_CALL(pprp->get_Value((LPVARIANT)v));
-
- return v;
- }
-
- VOID CdbProperty::SetValue(
- LPVARIANT pv)
- {
- DAOProperty * pprp = (DAOProperty *)GetInterface();
-
- DAOMFC_CALL(pprp->put_Value(*pv));
- }
-
- CString CdbProperty::GetName(
- VOID)
- {
- DAOProperty * pprp = (DAOProperty *)GetInterface();
- CdbBSTR bstr;
-
- if (!pprp)
- return (LPCTSTR)NULL;
-
- DAOMFC_CALL(pprp->get_Name(bstr));
-
- return bstr;
- }
-
- VOID CdbProperty::SetName(
- LPCTSTR pstrName)
- {
- DAOProperty * pprp = (DAOProperty *)GetInterface();
-
- DAOMFC_CALL(pprp->put_Name(STB(pstrName)));
- }
-
- SHORT CdbProperty::GetType(
- VOID)
- {
- DAOProperty * pprp = (DAOProperty *)GetInterface();
- SHORT s = 0;
-
- if (!pprp)
- return 0;
-
- DAOMFC_CALL(pprp->get_Type(&s));
-
- return s;
- }
-
- VOID CdbProperty::SetType(
- SHORT sType)
- {
- DAOProperty * pprp = (DAOProperty *)GetInterface();
-
- DAOMFC_CALL(pprp->put_Type(sType));
- }
-
- BOOL CdbProperty::GetInherited(
- VOID)
- {
- DAOProperty * pprp = (DAOProperty *)GetInterface();
- VARIANT_BOOL vb = 0;
-
- if (!pprp)
- return FALSE;
-
- DAOMFC_CALL(pprp->get_Inherited(&vb));
-
- return (BOOL)vb;
- }
-
-
- /*****************************************************************************
- * CdbParameter
- */
- // Administration
- CONSTRUCTOR CdbParameter::CdbParameter(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbParameter::CdbParameter(
- DAOParameter * pprm,
- BOOL bAddRef) // = FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)pprm, bAddRef);
- }
-
- CONSTRUCTOR CdbParameter::CdbParameter(
- const CdbParameter &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbParameter & CdbParameter::operator =(
- const CdbParameter &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbParameter::OnInterfaceChange(
- VOID)
- {
- DAOParameter * pprm = (DAOParameter *)GetInterface();
- DAOProperties * pprps = NULL;
-
- if (pprm)
- pprm->get_Properties(&pprps);
-
- Properties.SetInterface(pprps);
- }
-
- // Properties
- CString CdbParameter::GetName(
- VOID)
- {
- SPROPGET(DAOParameter, get_Name);
- }
-
- COleVariant CdbParameter::GetValue(
- VOID)
- {
- VPROPGET(DAOParameter, get_Value);
- }
-
- VOID CdbParameter::SetValue(
- LPVARIANT pv)
- {
- VPROPSET(DAOParameter, put_Value, pv);
- }
-
- SHORT CdbParameter::GetType(
- VOID)
- {
- WPROPGET(DAOParameter, get_Type);
- }
-
-
- /*****************************************************************************
- * CdbRelation
- */
- // Administration
- CONSTRUCTOR CdbRelation::CdbRelation(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbRelation::CdbRelation(
- DAORelation * prl,
- BOOL bAddRef) // = FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)prl, bAddRef);
- }
-
- CONSTRUCTOR CdbRelation::CdbRelation(
- const CdbRelation &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbRelation & CdbRelation::operator =(
- const CdbRelation &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbRelation::OnInterfaceChange(
- VOID)
- {
- DAORelation * prl = (DAORelation *)GetInterface();
- DAOProperties * pprps = NULL;
- DAOFields * pflds = NULL;
-
- if (prl)
- {
- prl->get_Properties(&pprps);
- prl->get_Fields(&pflds);
- }
-
- Properties.SetInterface(pprps);
- Fields.SetInterface(pflds);
- }
-
- // Properties
- CString CdbRelation::GetName(
- VOID)
- {
- SPROPGET(DAORelation, get_Name);
- }
-
- VOID CdbRelation::SetName(
- LPCTSTR pstr)
- {
- SPROPSET(DAORelation, put_Name, pstr);
- }
-
- CString CdbRelation::GetTable(
- VOID)
- {
- SPROPGET(DAORelation, get_Table);
- }
-
- VOID CdbRelation::SetTable(
- LPCTSTR pstr)
- {
- SPROPSET(DAORelation, put_Table, pstr);
- }
-
- CString CdbRelation::GetForeignTable(
- VOID)
- {
- SPROPGET(DAORelation, get_ForeignTable);
- }
-
- VOID CdbRelation::SetForeignTable(
- LPCTSTR pstr)
- {
- SPROPSET(DAORelation, put_ForeignTable, pstr);
- }
-
- LONG CdbRelation::GetAttributes(
- VOID)
- {
- LPROPGET(DAORelation, get_Attributes);
- }
-
- VOID CdbRelation::SetAttributes(
- LONG l)
- {
- LPROPSET(DAORelation, put_Attributes, l);
- }
-
-
- // Methods
- CdbField CdbRelation::CreateField(
- LPCTSTR pstrName, // = NULL
- LONG lType, // = -1
- LONG lSize) // = -1
- {
- DAORelation * prl = (DAORelation *)GetInterface();
- DAOField * pfld = NULL;
-
- if (!prl)
- return (DAOField *)NULL;
-
- DAOMFC_CALL(prl->CreateField(STV(pstrName), OLTV(lType), OLTV(lSize), &pfld));
-
- return pfld;
- }
-
-
- /*****************************************************************************
- * CdbUser
- */
- // Administration
- CONSTRUCTOR CdbUser::CdbUser(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbUser::CdbUser(
- DAOUser * pusr,
- BOOL bAddRef) // = FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)pusr, bAddRef);
- }
-
- CONSTRUCTOR CdbUser::CdbUser(
- const CdbUser &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbUser & CdbUser::operator =(
- const CdbUser &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbUser::OnInterfaceChange(
- VOID)
- {
- DAOUser * pusr = (DAOUser *)GetInterface();
- DAOProperties * pprps = NULL;
- DAOGroups * pgrps = NULL;
-
- if (pusr)
- {
- pusr->get_Properties(&pprps);
- pusr->get_Groups(&pgrps);
- }
-
- Properties.SetInterface(pprps);
- Groups.SetInterface(pgrps);
- }
-
- // Properties
- CString CdbUser::GetName(
- VOID)
- {
- SPROPGET(DAOUser, get_Name);
- }
-
- VOID CdbUser::SetName(
- LPCTSTR pstr)
- {
- SPROPSET(DAOUser, put_Name, pstr);
- }
-
- VOID CdbUser::SetPID(
- LPCTSTR pstr)
- {
- SPROPSET(DAOUser, put_PID, pstr);
- }
-
- VOID CdbUser::SetPassword(
- LPCTSTR pstr)
- {
- SPROPSET(DAOUser, put_Password, pstr);
- }
-
- // Methods
- VOID CdbUser::NewPassword(
- LPCTSTR pstrOld,
- LPCTSTR pstrNew)
- {
- DAOUser * pusr = (DAOUser *)GetInterface();
-
- DAOMFC_CALL(pusr->NewPassword(STB(pstrOld), STB(pstrNew)));
- }
-
- CdbGroup CdbUser::CreateGroup(
- LPCTSTR pstrName, // = NULL
- LPCTSTR pstrPID) // = NULL
- {
- DAOUser * pusr = (DAOUser *)GetInterface();
- DAOGroup * pgrp = NULL;
-
- if (!pusr)
- return FALSE;
-
- DAOMFC_CALL(pusr->CreateGroup(STV(pstrName), STV(pstrPID), &pgrp));
-
- return pgrp;
- }
-
- /*****************************************************************************
- * CdbGroup
- */
- // Administration
- CONSTRUCTOR CdbGroup::CdbGroup(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbGroup::CdbGroup(
- DAOGroup * pgrp,
- BOOL bAddRef) // = FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)pgrp, bAddRef);
- }
-
- CONSTRUCTOR CdbGroup::CdbGroup(
- const CdbGroup &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbGroup & CdbGroup::operator =(
- const CdbGroup &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbGroup::OnInterfaceChange(
- VOID)
- {
- DAOGroup * pgrp = (DAOGroup *)GetInterface();
- DAOProperties * pprps = NULL;
- DAOUsers * pusrs = NULL;
-
- if (pgrp)
- {
- pgrp->get_Properties(&pprps);
- pgrp->get_Users(&pusrs);
- }
-
- Properties.SetInterface(pprps);
- Users.SetInterface(pusrs);
- }
-
- // Properties
- CString CdbGroup::GetName(
- VOID)
- {
- SPROPGET(DAOGroup, get_Name);
- }
-
- VOID CdbGroup::SetName(
- LPCTSTR pstr)
- {
- SPROPSET(DAOGroup, put_Name, pstr);
- }
-
- VOID CdbGroup::SetPID(
- LPCTSTR pstr)
- {
- SPROPSET(DAOGroup, put_PID, pstr);
- }
-
- // Methods
- CdbUser CdbGroup::CreateUser(
- LPCTSTR pstrName, // = NULL
- LPCTSTR pstrPID, // = NULL
- LPCTSTR pstrPassword) // = NULL
- {
- DAOGroup * pgrp = (DAOGroup *)GetInterface();
- DAOUser * pusr = NULL;
-
- if (!pgrp)
- return FALSE;
-
- DAOMFC_CALL(pgrp->CreateUser(STV(pstrName), STV(pstrPID), STV(pstrPassword), &pusr));
-
- return pusr;
- }
-
-
- /*****************************************************************************
- * CdbDocument
- */
- // Administration
- CONSTRUCTOR CdbDocument::CdbDocument(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbDocument::CdbDocument(
- DAODocument * pdoc,
- BOOL bAddRef) // = FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)pdoc, bAddRef);
- }
-
- CONSTRUCTOR CdbDocument::CdbDocument(
- const CdbDocument &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbDocument & CdbDocument::operator =(
- const CdbDocument &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbDocument::OnInterfaceChange(
- VOID)
- {
- DAODocument * pdoc = (DAODocument *)GetInterface();
- DAOProperties * pprps = NULL;
-
- if (pdoc)
- {
- pdoc->get_Properties(&pprps);
- }
-
- Properties.SetInterface(pprps);
- }
-
- // Properties
- CString CdbDocument::GetName(
- VOID)
- {
- SPROPGET(DAODocument, get_Name);
- }
-
- CString CdbDocument::GetOwner(
- VOID)
- {
- SPROPGET(DAODocument, get_Owner);
- }
-
- VOID CdbDocument::SetOwner(
- LPCTSTR pstr)
- {
- SPROPSET(DAODocument, put_Owner, pstr);
- }
-
- CString CdbDocument::GetContainer(
- VOID)
- {
- SPROPGET(DAODocument, get_Container);
- }
-
- CString CdbDocument::GetUserName(
- VOID)
- {
- SPROPGET(DAODocument, get_UserName);
- }
-
- VOID CdbDocument::SetUserName(
- LPCTSTR pstr)
- {
- SPROPSET(DAODocument, put_UserName, pstr);
- }
-
- LONG CdbDocument::GetPermissions(
- VOID)
- {
- LPROPGET(DAODocument, get_Permissions);
- }
-
- VOID CdbDocument::SetPermissions(
- LONG l)
- {
- LPROPSET(DAODocument, put_Permissions, l);
- }
-
- COleDateTime CdbDocument::GetDateCreated(
- VOID)
- {
- DPROPGET(DAODocument, get_DateCreated);
- }
-
- COleDateTime CdbDocument::GetLastUpdated(
- VOID)
- {
- DPROPGET(DAODocument, get_LastUpdated);
- }
-
-
- /*****************************************************************************
- * CdbContainer
- */
- // Administration
- CONSTRUCTOR CdbContainer::CdbContainer(
- VOID)
- {
- }
-
- CONSTRUCTOR CdbContainer::CdbContainer(
- DAOContainer * pctn,
- BOOL bAddRef) // = FALSE
- {
- CdbOleObject::SetInterface((LPUNKNOWN)pctn, bAddRef);
- }
-
- CONSTRUCTOR CdbContainer::CdbContainer(
- const CdbContainer &o)
- {
- SetInterface(o.GetInterface(TRUE));
- }
-
- CdbContainer & CdbContainer::operator =(
- const CdbContainer &o)
- {
- SetInterface(o.GetInterface(TRUE));
- return *this;
- }
-
- VOID CdbContainer::OnInterfaceChange(
- VOID)
- {
- DAOContainer * pctn = (DAOContainer *)GetInterface();
- DAOProperties * pprps = NULL;
- DAODocuments * pdocs = NULL;
-
- if (pctn)
- {
- pctn->get_Properties(&pprps);
- pctn->get_Documents(&pdocs);
- }
-
- Properties.SetInterface(pprps);
- Documents.SetInterface(pdocs);
- }
-
- // Properties
- CString CdbContainer::GetName(
- VOID)
- {
- SPROPGET(DAOContainer, get_Name);
- }
-
- CString CdbContainer::GetOwner(
- VOID)
- {
- SPROPGET(DAOContainer, get_Owner);
- }
-
- VOID CdbContainer::SetOwner(
- LPCTSTR pstr)
- {
- SPROPSET(DAOContainer, put_Owner, pstr);
- }
-
- CString CdbContainer::GetUserName(
- VOID)
- {
- SPROPGET(DAOContainer, get_UserName);
- }
-
- VOID CdbContainer::SetUserName(
- LPCTSTR pstr)
- {
- SPROPSET(DAOContainer, put_UserName, pstr);
- }
-
- LONG CdbContainer::GetPermissions(
- VOID)
- {
- LPROPGET(DAOContainer, get_Permissions);
- }
-
- VOID CdbContainer::SetPermissions(
- LONG l)
- {
- LPROPSET(DAOContainer, put_Permissions, l);
- }
-
- BOOL CdbContainer::GetInherit(
- VOID)
- {
- BPROPGET(DAOContainer, get_Inherit);
- }
-
- VOID CdbContainer::SetInherit(
- BOOL b)
- {
- BPROPSET(DAOContainer, put_Inherit, b);
- }
-
- /*****************************************************************************
- * CdbIndexFields (special case for index fields)
- */
- CdbField CdbIndexFields::Item(
- LPCTSTR pstr)
- {
- DAOIndexFields * pflds = (DAOIndexFields *)GetInterface();
- VARIANT v;
- DAOField * pfld = NULL;
-
- if (!pflds)
- return (DAOField *)NULL;
-
- VariantInit(&v);
- DAOMFC_CALL(pflds->get_Item(STV(pstr), &v));
-
- if (v.vt == VT_DISPATCH)
- {
- v.pdispVal->QueryInterface(dbIID_IDAOField, (LPVOID *)&pfld);
- v.pdispVal->Release();
- }
-
- return pfld;
- }
-
- CdbField CdbIndexFields::Item(
- LONG i)
- {
- DAOIndexFields * pflds = (DAOIndexFields *)GetInterface();
- VARIANT v;
- DAOField * pfld = NULL;
-
- if (!pflds)
- return (DAOField *)NULL;
-
- VariantInit(&v);
- DAOMFC_CALL(pflds->get_Item(LTV(i), &v));
-
- if (v.vt == VT_DISPATCH)
- {
- v.pdispVal->QueryInterface(dbIID_IDAOField, (LPVOID *)&pfld);
- v.pdispVal->Release();
- }
-
- return pfld;
- }
-
- CdbObject CdbIndexFields::ObItem(
- LPCTSTR pstr)
- {
- DAOIndexFields * pflds = (DAOIndexFields *)GetInterface();
- VARIANT v;
- DAOField * pfld = NULL;
-
- if (!pflds)
- return (DAOFields *)NULL;
-
- VariantInit(&v);
- DAOMFC_CALL(pflds->get_Item(STV(pstr), &v));
-
- if (v.vt == VT_DISPATCH)
- {
- v.pdispVal->QueryInterface(dbIID_IDAOField, (LPVOID *)&pfld);
- v.pdispVal->Release();
- }
-
- return (LPUNKNOWN)pfld;
- }
-
- CdbObject CdbIndexFields::ObItem(
- LONG i)
- {
- DAOIndexFields * pflds = (DAOIndexFields *)GetInterface();
- VARIANT v;
- DAOField * pfld = NULL;
-
- if (!pflds)
- return (DAOFields *)NULL;
-
- VariantInit(&v);
- DAOMFC_CALL(pflds->get_Item(LTV(i), &v));
-
- if (v.vt == VT_DISPATCH)
- {
- v.pdispVal->QueryInterface(dbIID_IDAOField, (LPVOID *)&pfld);
- v.pdispVal->Release();
- }
-
- return (LPUNKNOWN)pfld;
- }
-
-
-
- /*****************************************************************************
- * CdbBSTR
- */
- CONSTRUCTOR CdbBSTR::CdbBSTR(
- BSTR b) // = NULL
- {
- m_bstr = b;
- }
-
- DESTRUCTOR CdbBSTR::~CdbBSTR(
- VOID)
- {
- if (m_bstr)
- SysFreeString(m_bstr);
- }
-
- CdbBSTR::operator BSTR *(
- VOID)
- {
- return &m_bstr;
- }
-
- CdbBSTR::operator LPCTSTR(
- VOID)
- {
- return (LPCTSTR)m_bstr;
- }
-
- HRESULT CdbWideFromAnsi(
- LPSTR pstr,
- unsigned int cb,
- BSTR * pbstr)
- {
- BSTR bstrNew;
-
- if (!(bstrNew = SysAllocStringLen(NULL, cb)))
- return ResultFromScode(E_OUTOFMEMORY);
-
- // Convert from ANSI to WIDE if char.s exist
- if (cb && !(cb = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pstr,
- cb, (LPWSTR)bstrNew, cb)))
- {
- SysFreeString(bstrNew);
- return ResultFromScode(E_OUTOFMEMORY);
- }
-
- // Make sure it's NULL terminated
- ((LPWSTR)(bstrNew))[cb] = L'\0';
-
- *pbstr = bstrNew;
-
- return NOERROR;
- }
-