// MyProviderDS.h : Declaration of the CMyProviderSource // // This is a part of the Active Template Library. // Copyright (C) 1998 Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // ActiveX Template Library Reference and related // electronic documentation provided with the library. // See these sources for detailed information regarding the // ActiveX Template Library product. #ifndef __CMyProviderSource_H_ #define __CMyProviderSource_H_ #include "resource.h" // main symbols #include "MyProviderRS.h" ///////////////////////////////////////////////////////////////////////////// // CDataSource class ATL_NO_VTABLE CMyProviderSource : public CComObjectRootEx, public CComCoClass, public IDBCreateSessionImpl, public IDBInitializeImpl, public IDBPropertiesImpl, public IPersistImpl, public IInternalConnectionImpl { public: CMyProviderSource() { CoInitialize(NULL); CoUninitialize(); ATLTRACE2(atlTraceDBProvider, 0, "Now in the data source constructor\n"); } ~CMyProviderSource() { ATLTRACE2(atlTraceDBProvider, 0, "Now in the data source destructor\n"); // MessageBox(NULL, _T("Foo"), _T("Bar"), MB_OK); } HRESULT FinalConstruct() { return FInit(); } HRESULT IsValidValue(ULONG iCurSet, DBPROP* pDBProp) { ATLASSERT(pDBProp != NULL); CComVariant var = pDBProp->vValue; switch (pDBProp->dwPropertyID) { case DBPROP_INIT_MODE: { LONG lAcceptable = ~(DB_MODE_READWRITE | DB_MODE_SHARE_EXCLUSIVE | DB_MODE_SHARE_DENY_NONE); if ((var.lVal & lAcceptable)) return S_FALSE; } break; case DBPROP_INIT_PROMPT: if (var.iVal != DBPROMPT_NOPROMPT && var.iVal != DBPROMPT_PROMPT && var.iVal != DBPROMPT_COMPLETE && var.iVal != DBPROMPT_COMPLETEREQUIRED) return S_FALSE; case DBPROP_INIT_TIMEOUT: if (var.lVal < 0) return S_FALSE; default: break; } return IDBPropertiesImpl::IsValidValue(iCurSet, pDBProp); } DECLARE_REGISTRY_RESOURCEID(IDR_MYPROVIDER) BEGIN_PROPSET_MAP(CMyProviderSource) BEGIN_PROPERTY_SET(DBPROPSET_DATASOURCEINFO) PROPERTY_INFO_ENTRY(ACTIVESESSIONS) PROPERTY_INFO_ENTRY(ASYNCTXNABORT) PROPERTY_INFO_ENTRY(ASYNCTXNCOMMIT) PROPERTY_INFO_ENTRY(BYREFACCESSORS) PROPERTY_INFO_ENTRY_VALUE(CATALOGLOCATION, DBPROPVAL_CL_START) PROPERTY_INFO_ENTRY(CATALOGTERM) PROPERTY_INFO_ENTRY(CATALOGUSAGE) PROPERTY_INFO_ENTRY(COLUMNDEFINITION) PROPERTY_INFO_ENTRY(CONCATNULLBEHAVIOR) PROPERTY_INFO_ENTRY(DATASOURCENAME) PROPERTY_INFO_ENTRY(DATASOURCEREADONLY) PROPERTY_INFO_ENTRY(DBMSNAME) PROPERTY_INFO_ENTRY(DBMSVER) PROPERTY_INFO_ENTRY_VALUE(DSOTHREADMODEL, DBPROPVAL_RT_FREETHREAD) PROPERTY_INFO_ENTRY(GROUPBY) PROPERTY_INFO_ENTRY(HETEROGENEOUSTABLES) PROPERTY_INFO_ENTRY(IDENTIFIERCASE) PROPERTY_INFO_ENTRY(MAXINDEXSIZE) PROPERTY_INFO_ENTRY(MAXROWSIZE) PROPERTY_INFO_ENTRY(MAXROWSIZEINCLUDESBLOB) PROPERTY_INFO_ENTRY(MAXTABLESINSELECT) PROPERTY_INFO_ENTRY(MULTIPLEPARAMSETS) PROPERTY_INFO_ENTRY(MULTIPLERESULTS) PROPERTY_INFO_ENTRY(MULTIPLESTORAGEOBJECTS) PROPERTY_INFO_ENTRY(MULTITABLEUPDATE) PROPERTY_INFO_ENTRY(NULLCOLLATION) PROPERTY_INFO_ENTRY(OLEOBJECTS) PROPERTY_INFO_ENTRY(ORDERBYCOLUMNSINSELECT) PROPERTY_INFO_ENTRY(OUTPUTPARAMETERAVAILABILITY) PROPERTY_INFO_ENTRY(PERSISTENTIDTYPE) PROPERTY_INFO_ENTRY(PREPAREABORTBEHAVIOR) PROPERTY_INFO_ENTRY(PREPARECOMMITBEHAVIOR) PROPERTY_INFO_ENTRY(PROCEDURETERM) PROPERTY_INFO_ENTRY(PROVIDERNAME) PROPERTY_INFO_ENTRY(PROVIDEROLEDBVER) PROPERTY_INFO_ENTRY(PROVIDERVER) PROPERTY_INFO_ENTRY(QUOTEDIDENTIFIERCASE) PROPERTY_INFO_ENTRY(ROWSETCONVERSIONSONCOMMAND) PROPERTY_INFO_ENTRY(SCHEMATERM) PROPERTY_INFO_ENTRY(SCHEMAUSAGE) PROPERTY_INFO_ENTRY(STRUCTUREDSTORAGE) PROPERTY_INFO_ENTRY(SUBQUERIES) PROPERTY_INFO_ENTRY(TABLETERM) PROPERTY_INFO_ENTRY(USERNAME) END_PROPERTY_SET(DBPROPSET_DATASOURCEINFO) BEGIN_PROPERTY_SET(DBPROPSET_DBINIT) PROPERTY_INFO_ENTRY(AUTH_PASSWORD) PROPERTY_INFO_ENTRY(AUTH_PERSIST_SENSITIVE_AUTHINFO) PROPERTY_INFO_ENTRY(AUTH_USERID) PROPERTY_INFO_ENTRY(INIT_DATASOURCE) PROPERTY_INFO_ENTRY(INIT_HWND) PROPERTY_INFO_ENTRY(INIT_LCID) PROPERTY_INFO_ENTRY(INIT_LOCATION) PROPERTY_INFO_ENTRY(INIT_PROVIDERSTRING) END_PROPERTY_SET(DBPROPSET_DBINIT) BEGIN_PROPERTY_SET(DBPROPSET_DATASOURCE) PROPERTY_INFO_ENTRY(CURRENTCATALOG) END_PROPERTY_SET(DBPROPSET_DATASOURCE) CHAIN_PROPERTY_SET(CMyProviderSession) END_PROPSET_MAP() typedef IDBCreateSessionImpl DBCreateSessionClass; BEGIN_COM_MAP(CMyProviderSource) COM_INTERFACE_ENTRY_IID(IID_IDBCreateSession, DBCreateSessionClass) COM_INTERFACE_ENTRY(IDBInitialize) COM_INTERFACE_ENTRY(IDBProperties) COM_INTERFACE_ENTRY(IPersist) COM_INTERFACE_ENTRY(IInternalConnection) END_COM_MAP() public: }; #endif //__CMyProviderSource_H_