home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / mfc / include / afxdao.h < prev    next >
C/C++ Source or Header  |  1998-06-16  |  39KB  |  1,327 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #ifndef __AFXDAO_H
  12. #define __AFXDAO_H
  13.  
  14. #ifdef _AFX_NO_DAO_SUPPORT
  15.     #error DAO Database classes not supported in this library variant.
  16. #endif
  17.  
  18. #ifndef __AFXDISP_H__
  19.     #include <afxdisp.h>    // Must include this before dao headers
  20. #endif
  21. #ifndef _DBDAOINT_H_
  22.     #include <dbdaoint.h>
  23. #endif
  24. #ifndef _DAOGETRW_H_
  25.     #include <daogetrw.h>
  26. #endif
  27. #ifndef _DBDAOID_H_
  28.     #include <dbdaoid.h>
  29. #endif
  30. #ifndef _DBDAOERR_H_
  31.     #include <dbdaoerr.h>
  32. #endif
  33.  
  34. #ifndef __AFXDB__H__
  35.     #include <afxdb_.h> // shared header with ODBC database classes
  36. #endif
  37.  
  38. #ifndef __AFXEXT_H__
  39.     #include <afxext.h> // for CFormView
  40. #endif
  41.  
  42. #ifdef _AFX_MINREBUILD
  43. #pragma component(minrebuild, off)
  44. #endif
  45. #ifndef _AFX_FULLTYPEINFO
  46. #pragma component(mintypeinfo, on)
  47. #endif
  48.  
  49. #ifndef _AFX_NOFORCE_LIBS
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // Win32 libraries
  53.  
  54. #ifdef _AFXDLL
  55.     #if defined(_DEBUG) && !defined(_AFX_MONOLITHIC)
  56.         #ifndef _UNICODE
  57.             #pragma comment(lib, "mfco42d.lib")
  58.             #pragma comment(lib, "mfcd42d.lib")
  59.         #else
  60.             #pragma comment(lib, "mfco42ud.lib")
  61.             #pragma comment(lib, "mfcd42ud.lib")
  62.         #endif
  63.     #endif
  64.  
  65. #endif
  66.  
  67. #pragma comment(lib, "daouuid.lib")
  68.  
  69. #endif //!_AFX_NOFORCE_LIBS
  70.  
  71. #ifdef _AFX_PACKING
  72. #pragma pack(push, _AFX_PACKING)
  73. #endif
  74.  
  75. ////////////////////////////////////////////////////////////////////////
  76. // AFXDAO - MFC Database support using DAO
  77.  
  78. // Classes declared in this file
  79.  
  80.     // CException
  81.         class CDaoException;    // DAO error/exception handling
  82.  
  83.     // CObject
  84.         class CDaoRecordView;
  85.         class CDaoWorkspace;    // DAO engine/transaction/security manager
  86.         class CDaoDatabase;     // DAO database manager
  87.         class CDaoRecordset;    // DAO result set manager
  88.         class CDaoTableDef;     // DAO base table manager
  89.         class CDaoQueryDef;     // DAO query manager
  90.  
  91.     // Non-CObject classes
  92.         class CDaoFieldExchange;
  93.         struct CDaoFieldCache;
  94.         struct CDaoErrorInfo;
  95.         struct CDaoWorkspaceInfo;
  96.         struct CDaoDatabaseInfo;
  97.         struct CDaoTableDefInfo;
  98.         struct CDaoFieldInfo;
  99.         struct CDaoIndexInfo;
  100.         struct CDaoRelationInfo;
  101.         struct CDaoQueryDefInfo;
  102.         struct CDaoParameterInfo;
  103.  
  104. /////////////////////////////////////////////////////////////////////////////
  105. // AFXDLL support
  106.  
  107. #undef AFX_DATA
  108. #define AFX_DATA AFX_DB_DATA
  109.  
  110. ////////////////////////////////////////////////////////////////////////
  111. // Data caching structures
  112. struct CDaoFieldCache
  113. {
  114.     void* m_pvData;     // Pointer to cached data of any supported type.
  115.     BYTE m_nStatus;     // (NULL) status cache.
  116.     BYTE m_nDataType;       // Type of data cached.
  117. };
  118.  
  119. ////////////////////////////////////////////////////////////////////////
  120. // Info structures
  121.  
  122. struct CDaoErrorInfo
  123. {
  124. // Attributes
  125.     long m_lErrorCode;
  126.     CString m_strSource;
  127.     CString m_strDescription;
  128.     CString m_strHelpFile;
  129.     long m_lHelpContext;
  130.  
  131. #ifdef _DEBUG
  132.     virtual void Dump(CDumpContext& dc) const;
  133. #endif
  134. };
  135.  
  136. struct CDaoWorkspaceInfo
  137. {
  138. // Attributes
  139.     CString m_strName;              // Primary
  140.     CString m_strUserName;          // Secondary
  141.     BOOL m_bIsolateODBCTrans;       // All
  142.  
  143. #ifdef _DEBUG
  144.     virtual void Dump(CDumpContext& dc) const;
  145. #endif
  146. };
  147.  
  148. struct CDaoDatabaseInfo
  149. {
  150. // Attributes
  151.     CString m_strName;              // Primary
  152.     BOOL m_bUpdatable;              // Primary
  153.     BOOL m_bTransactions;           // Primary
  154.     CString m_strVersion;           // Secondary
  155.     long m_lCollatingOrder;         // Secondary
  156.     short m_nQueryTimeout;          // Secondary
  157.     CString m_strConnect;           // All
  158.  
  159. #ifdef _DEBUG
  160.     virtual void Dump(CDumpContext& dc) const;
  161. #endif
  162. };
  163.  
  164. struct CDaoTableDefInfo
  165. {
  166. // Attributes
  167.     CString m_strName;              // Primary
  168.     BOOL m_bUpdatable;              // Primary
  169.     long m_lAttributes;             // Primary
  170.     COleDateTime m_dateCreated;     // Secondary
  171.     COleDateTime m_dateLastUpdated; // Secondary
  172.     CString m_strSrcTableName;      // Secondary
  173.     CString m_strConnect;           // Secondary
  174.     CString m_strValidationRule;    // All
  175.     CString m_strValidationText;    // All
  176.     long m_lRecordCount;            // All
  177.  
  178. #ifdef _DEBUG
  179.     virtual void Dump(CDumpContext& dc) const;
  180. #endif
  181. };
  182.  
  183. struct CDaoFieldInfo
  184. {
  185. // Attributes
  186.     CString m_strName;              // Primary
  187.     short m_nType;                  // Primary
  188.     long m_lSize;                   // Primary
  189.     long m_lAttributes;             // Primary
  190.     short m_nOrdinalPosition;       // Secondary
  191.     BOOL m_bRequired;               // Secondary
  192.     BOOL m_bAllowZeroLength;        // Secondary
  193.     long m_lCollatingOrder;         // Secondary
  194.     CString m_strForeignName;       // Secondary
  195.     CString m_strSourceField;       // Secondary
  196.     CString m_strSourceTable;       // Secondary
  197.     CString m_strValidationRule;    // All
  198.     CString m_strValidationText;    // All
  199.     CString m_strDefaultValue;      // All
  200.  
  201. #ifdef _DEBUG
  202.     virtual void Dump(CDumpContext& dc) const;
  203. #endif
  204. };
  205.  
  206. struct CDaoIndexFieldInfo
  207. {
  208. // Attributes
  209.     CString m_strName;              // Primary
  210.     BOOL m_bDescending;             // Primary
  211.  
  212. #ifdef _DEBUG
  213.     virtual void Dump(CDumpContext& dc) const;
  214. #endif
  215. };
  216.  
  217. struct CDaoIndexInfo
  218. {
  219. // Constructors
  220.     CDaoIndexInfo();
  221.  
  222. // Attributes
  223.     CString m_strName;                      // Primary
  224.     CDaoIndexFieldInfo* m_pFieldInfos;      // Primary
  225.     short m_nFields;                        // Primary
  226.     BOOL m_bPrimary;                        // Secondary
  227.     BOOL m_bUnique;                         // Secondary
  228.     BOOL m_bClustered;                      // Secondary
  229.     BOOL m_bIgnoreNulls;                    // Secondary
  230.     BOOL m_bRequired;                       // Secondary
  231.     BOOL m_bForeign;                        // Secondary
  232.     long m_lDistinctCount;                  // All
  233.  
  234. // Implementation
  235.     virtual ~CDaoIndexInfo();
  236.     BOOL m_bCleanupFieldInfo;
  237.  
  238. #ifdef _DEBUG
  239.     virtual void Dump(CDumpContext& dc) const;
  240. #endif
  241. };
  242.  
  243. struct CDaoRelationFieldInfo
  244. {
  245. // Attributes
  246.     CString m_strName;              // Primary
  247.     CString m_strForeignName;       // Primary
  248.  
  249. #ifdef _DEBUG
  250.     virtual void Dump(CDumpContext& dc) const;
  251. #endif
  252. };
  253.  
  254. struct CDaoRelationInfo
  255. {
  256. // Constructor
  257.     CDaoRelationInfo();
  258.  
  259. // Attributes
  260.     CString m_strName;              // Primary
  261.     CString m_strTable;             // Primary
  262.     CString m_strForeignTable;      // Primary
  263.     long m_lAttributes;             // Secondary
  264.     CDaoRelationFieldInfo* m_pFieldInfos;   // Secondary
  265.     short m_nFields;                // Secondary
  266.  
  267. // Implementation
  268.     virtual ~CDaoRelationInfo();
  269.     BOOL m_bCleanupFieldInfo;
  270.  
  271. #ifdef _DEBUG
  272.     virtual void Dump(CDumpContext& dc) const;
  273. #endif
  274. };
  275.  
  276. struct CDaoQueryDefInfo
  277. {
  278. // Attributes
  279.     CString m_strName;              // Primary
  280.     short m_nType;                  // Primary
  281.     COleDateTime m_dateCreated;     // Secondary
  282.     COleDateTime m_dateLastUpdated; // Secondary
  283.     BOOL m_bUpdatable;              // Secondary
  284.     BOOL m_bReturnsRecords;         // Secondary
  285.     CString m_strSQL;               // All
  286.     CString m_strConnect;           // All
  287.     short m_nODBCTimeout;           // See readme
  288.  
  289. #ifdef _DEBUG
  290.     virtual void Dump(CDumpContext& dc) const;
  291. #endif
  292. };
  293.  
  294. struct CDaoParameterInfo
  295. {
  296. // Attributes
  297.     CString m_strName;              // Primary
  298.     short m_nType;                  // Primary
  299.     COleVariant m_varValue;         // Secondary
  300.  
  301. #ifdef _DEBUG
  302.     virtual void Dump(CDumpContext& dc) const;
  303. #endif
  304. };
  305.  
  306. ////////////////////////////////////////////////////////////////////////
  307. // DAO Helpers
  308. //
  309.  
  310. // Flags for getting and/or setting object properties
  311. #define AFX_DAO_PRIMARY_INFO    0x00000001  // Get only primary
  312. #define AFX_DAO_SECONDARY_INFO  0x00000002  // Get primary & secondary
  313. #define AFX_DAO_ALL_INFO        0x00000004  // Get All info
  314.  
  315. // Jet engine TRUE/FALSE definitions
  316. #define AFX_DAO_TRUE                    (-1L)
  317. #define AFX_DAO_FALSE                   0
  318.  
  319. // Set CDaoRecordset::Open option to use m_nDefaultType
  320. #define AFX_DAO_USE_DEFAULT_TYPE        (-1L)
  321.  
  322. // Flags used for Move/Find
  323. #define AFX_DAO_NEXT                    (+1L)
  324. #define AFX_DAO_PREV                    (-1L)
  325. #define AFX_DAO_FIRST                   LONG_MIN
  326. #define AFX_DAO_LAST                    LONG_MAX
  327.  
  328. // Default sizes for DFX function PreAlloc sizes
  329. #define AFX_DAO_TEXT_DEFAULT_SIZE       255
  330. #define AFX_DAO_BINARY_DEFAULT_SIZE     2048
  331. #define AFX_DAO_LONGBINARY_DEFAULT_SIZE 32768
  332.  
  333. // Flag used for DFX functions dwBindOptions bitmask
  334. #define AFX_DAO_ENABLE_FIELD_CACHE      0x01
  335. #define AFX_DAO_DISABLE_FIELD_CACHE     0
  336. #define AFX_DAO_CACHE_BY_VALUE          0x80    // MFC Internal
  337.  
  338. // Field Flags, used to indicate status of fields
  339. #define AFX_DAO_FIELD_FLAG_DIRTY            0x01
  340. #define AFX_DAO_FIELD_FLAG_NULL             0x02
  341. #define AFX_DAO_FIELD_FLAG_NULLABLE_KNOWN   0x04
  342. #define AFX_DAO_FIELD_FLAG_NULLABLE         0x08
  343.  
  344. // Extended error codes
  345. #define NO_AFX_DAO_ERROR                        0
  346. #define AFX_DAO_ERROR_MIN                       2000
  347. #define AFX_DAO_ERROR_ENGINE_INITIALIZATION     AFX_DAO_ERROR_MIN + 0
  348. #define AFX_DAO_ERROR_DFX_BIND                  AFX_DAO_ERROR_MIN + 1
  349. #define AFX_DAO_ERROR_OBJECT_NOT_OPEN           AFX_DAO_ERROR_MIN + 2
  350. #define AFX_DAO_ERROR_MAX                       AFX_DAO_ERROR_MIN + 2
  351.  
  352. // Object status flags
  353. #define AFX_DAO_IMPLICIT_WS                     0x01
  354. #define AFX_DAO_IMPLICIT_DB                     0x02
  355. #define AFX_DAO_IMPLICIT_QD                     0x04
  356. #define AFX_DAO_IMPLICIT_TD                     0x08
  357. #define AFX_DAO_IMPLICIT_CLOSE                  0x40
  358. #define AFX_DAO_DEFAULT_WS                      0x80
  359.  
  360. // CDaoRecordView status flags
  361. #define AFX_DAOVIEW_SCROLL_NEXT                 0x01
  362. #define AFX_DAOVIEW_SCROLL_LAST                 0x02
  363. #define AFX_DAOVIEW_SCROLL_BACKWARD             0x04
  364.  
  365. // Logging helpers
  366. void AFXAPI AfxDaoCheck(SCODE scode, LPCSTR lpszDaoCall,
  367.     LPCSTR lpszFile, int nLine, int nError = NO_AFX_DAO_ERROR,
  368.     BOOL bMemOnly = FALSE);
  369.  
  370. #ifdef _DEBUG
  371. void AFXAPI AfxDaoTrace(SCODE scode, LPCSTR lpszDaoCall,
  372.     LPCSTR lpszFile, int nLine);
  373. #endif
  374.  
  375. #ifdef _DEBUG
  376. #define DAO_CHECK(f)            AfxDaoCheck(f, #f, THIS_FILE, __LINE__)
  377. #define DAO_CHECK_ERROR(f, err) AfxDaoCheck(f, #f, THIS_FILE, __LINE__, err)
  378. #define DAO_CHECK_MEM(f)        AfxDaoCheck(f, #f, THIS_FILE, __LINE__, \
  379.                                     NO_AFX_DAO_ERROR, TRUE)
  380. #define DAO_TRACE(f)            AfxDaoTrace(f, #f, THIS_FILE, __LINE__)
  381. #else
  382. #define DAO_CHECK(f)            AfxDaoCheck(f, NULL, NULL, 0)
  383. #define DAO_CHECK_ERROR(f, err) AfxDaoCheck(f, NULL, NULL, 0, err)
  384. #define DAO_CHECK_MEM(f)        AfxDaoCheck(f, NULL, NULL, 0, \
  385.                                     NO_AFX_DAO_ERROR, TRUE)
  386. #define DAO_TRACE(f)            f
  387. #endif
  388.  
  389. /////////////////////////////////////////////////////////////////////////////
  390. // CDaoFieldExchange - for field exchange
  391. class CDaoFieldExchange
  392. {
  393. // Attributes
  394. public:
  395.     enum DFX_Operation
  396.     {
  397.         AddToParameterList,     // builds PARAMETERS clause
  398.         AddToSelectList,        // builds SELECT clause
  399.         BindField,              // sets up binding structure
  400.         BindParam,              // sets parameter values
  401.         Fixup,                  // sets NULL status
  402.         AllocCache,             // allocates cache used for dirty check
  403.         StoreField,             // saves current record to cache
  404.         LoadField,              // restores cached data to member vars
  405.         FreeCache,              // frees cache
  406.         SetFieldNull,           // sets field status & value to NULL
  407.         MarkForAddNew,          // marks fields dirty if not PSEUDO NULL
  408.         MarkForEdit,            // marks fields dirty if don't match cache
  409.         SetDirtyField,          // sets field values marked as dirty
  410. #ifdef _DEBUG
  411.         DumpField,
  412. #endif
  413.         MaxDFXOperation,        // dummy operation type for input checking
  414.     };
  415.  
  416.     UINT m_nOperation;          // type of exchange operation
  417.     CDaoRecordset* m_prs;       // recordset handle
  418.  
  419. // Operations
  420. public:
  421.     enum FieldType
  422.     {
  423.         none,
  424.         outputColumn,
  425.         param,
  426.     };
  427.  
  428.     void SetFieldType(UINT nFieldType);
  429.     BOOL IsValidOperation();
  430.  
  431. // Implementation
  432. public:
  433.     CDaoFieldExchange(UINT nOperation, CDaoRecordset* prs,
  434.         void* pvField = NULL);
  435.  
  436.     void Default(LPCTSTR lpszName, void* pv, DWORD dwFieldType,
  437.         DWORD dwBindOptions = 0);
  438.  
  439.     static void PASCAL AppendParamType(CString& strParamList, DWORD dwParamType);
  440.     static CDaoFieldCache* PASCAL GetCacheValue(CDaoRecordset* prs, void* pv);
  441.     static void PASCAL SetNullValue(void* pv, DWORD dwDataType);
  442.     static BOOL PASCAL IsNullValue(void* pv, DWORD dwDataType);
  443.     static void PASCAL AllocCacheValue(CDaoFieldCache*& pCache, DWORD dwDataType);
  444.     static void PASCAL DeleteCacheValue(CDaoFieldCache* pCache, DWORD dwDataType);
  445.     static void PASCAL CopyValue(void* pvSrc, void* pvDest, DWORD dwDataType);
  446.     static BOOL PASCAL CompareValue(void* pvSrc, void* pvDest, DWORD dwDataType);
  447.     static void PASCAL FillVariant(void* pvValue, DWORD dwDataType, COleVariant** ppVar);
  448.  
  449.     // Current type of field
  450.     UINT m_nFieldType;
  451.     void* m_pvField;
  452.     UINT m_nField;
  453.     UINT m_nParam;
  454.     UINT m_nFieldFound;
  455.  
  456. #ifdef _DEBUG
  457.     CDumpContext* m_pdcDump;
  458. #endif //_DEBUG
  459. };
  460.  
  461. /////////////////////////////////////////////////////////////////////////////
  462. // Standard RecordSet Field Exchange routines
  463.  
  464. // variable length data
  465. void AFXAPI DFX_Text(CDaoFieldExchange* pFX, LPCTSTR lpszName,
  466.     CString& value, int nPreAllocSize = AFX_DAO_TEXT_DEFAULT_SIZE,
  467.     DWORD dwBindOptions = AFX_DAO_ENABLE_FIELD_CACHE);
  468. void AFXAPI DFX_Binary(CDaoFieldExchange* pFX, LPCTSTR lpszName,
  469.     CByteArray& value, int nPreAllocSize = AFX_DAO_BINARY_DEFAULT_SIZE,
  470.     DWORD dwBindOptions = 0);
  471. void AFXAPI DFX_LongBinary(CDaoFieldExchange* pFX, LPCTSTR lpszName,
  472.     CLongBinary& value, DWORD dwPreAllocSize = AFX_DAO_LONGBINARY_DEFAULT_SIZE,
  473.     DWORD dwBndOptions = 0);
  474.  
  475. //fixed length data
  476. void AFXAPI DFX_Bool(CDaoFieldExchange* pFX, LPCTSTR lpszName,
  477.     BOOL& value, DWORD dwBindOptions = AFX_DAO_ENABLE_FIELD_CACHE);
  478. void AFXAPI DFX_Byte(CDaoFieldExchange* pFX, LPCTSTR lpszName,
  479.     BYTE& value, DWORD dwBindOptions = AFX_DAO_ENABLE_FIELD_CACHE);
  480. void AFXAPI DFX_Short(CDaoFieldExchange* pFX, LPCTSTR lpszName,
  481.     short& value, DWORD dwBindOptions = AFX_DAO_ENABLE_FIELD_CACHE);
  482. void AFXAPI DFX_Long(CDaoFieldExchange* pFX, LPCTSTR lpszName,
  483.     long& value, DWORD dwBindOptions = AFX_DAO_ENABLE_FIELD_CACHE);
  484. void AFXAPI DFX_Currency(CDaoFieldExchange* pFX, LPCTSTR lpszName,
  485.     COleCurrency& value, DWORD dwBindOptions = AFX_DAO_ENABLE_FIELD_CACHE);
  486. void AFXAPI DFX_Single(CDaoFieldExchange* pFX, LPCTSTR lpszName,
  487.     float& value, DWORD dwBindOptions = AFX_DAO_ENABLE_FIELD_CACHE);
  488. void AFXAPI DFX_Double(CDaoFieldExchange* pFX, LPCTSTR lpszName,
  489.     double& value, DWORD dwBindOptions = AFX_DAO_ENABLE_FIELD_CACHE);
  490. void AFXAPI DFX_DateTime(CDaoFieldExchange* pFX, LPCTSTR lpszName,
  491.     COleDateTime& value, DWORD dwBindOptions = AFX_DAO_ENABLE_FIELD_CACHE);
  492.  
  493. //////////////////////////////////////////////////////////////////////////
  494. // Database Dialog Data Exchange cover routines
  495. // Cover routines provide database semantics on top of DDX routines
  496.  
  497. // simple text operations
  498. void AFXAPI DDX_FieldText(CDataExchange* pDX, int nIDC, BOOL& value,
  499.     CDaoRecordset* pRecordset);
  500. void AFXAPI DDX_FieldText(CDataExchange* pDX, int nIDC, BYTE& value,
  501.     CDaoRecordset* pRecordset);
  502. void AFXAPI DDX_FieldText(CDataExchange* pDX, int nIDC, short& value,
  503.     CDaoRecordset* pRecordset);
  504. void AFXAPI DDX_FieldText(CDataExchange* pDX, int nIDC, long& value,
  505.     CDaoRecordset* pRecordset);
  506. void AFXAPI DDX_FieldText(CDataExchange* pDX, int nIDC, COleCurrency& value,
  507.     CDaoRecordset* pRecordset);
  508. void AFXAPI DDX_FieldText(CDataExchange* pDX, int nIDC, DWORD& value,
  509.     CDaoRecordset* pRecordset);
  510. void AFXAPI DDX_FieldText(CDataExchange* pDX, int nIDC, float& value,
  511.     CDaoRecordset* pRecordset);
  512. void AFXAPI DDX_FieldText(CDataExchange* pDX, int nIDC, double& value,
  513.     CDaoRecordset* pRecordset);
  514. void AFXAPI DDX_FieldText(CDataExchange* pDX, int nIDC, COleDateTime& value,
  515.     CDaoRecordset* pRecordset);
  516. void AFXAPI DDX_FieldText(CDataExchange* pDX, int nIDC, CString& value,
  517.     CDaoRecordset* pRecordset);
  518. void AFXAPI DDX_FieldText(CDataExchange* pDX, int nIDC, LPTSTR pstrValue,
  519.     int nMaxLen, CDaoRecordset* pRecordset);
  520.  
  521. // special control types
  522. void AFXAPI DDX_FieldCheck(CDataExchange* pDX, int nIDC, int& value,
  523.     CDaoRecordset* pRecordset);
  524. void AFXAPI DDX_FieldRadio(CDataExchange* pDX, int nIDC, int& value,
  525.     CDaoRecordset* pRecordset);
  526. void AFXAPI DDX_FieldLBString(CDataExchange* pDX, int nIDC,
  527.     CString& value, CDaoRecordset* pRecordset);
  528. void AFXAPI DDX_FieldCBString(CDataExchange* pDX, int nIDC,
  529.     CString& value, CDaoRecordset* pRecordset);
  530. void AFXAPI DDX_FieldLBStringExact(CDataExchange* pDX, int nIDC,
  531.     CString& value, CDaoRecordset* pRecordset);
  532. void AFXAPI DDX_FieldCBStringExact(CDataExchange* pDX, int nIDC,
  533.     CString& value, CDaoRecordset* pRecordset);
  534. void AFXAPI DDX_FieldLBIndex(CDataExchange* pDX, int nIDC, int& index,
  535.     CDaoRecordset* pRecordset);
  536. void AFXAPI DDX_FieldCBIndex(CDataExchange* pDX, int nIDC, int& index,
  537.     CDaoRecordset* pRecordset);
  538. void AFXAPI DDX_FieldLBStringExact(CDataExchange* pDX, int nIDC, CString& value,
  539.     CDaoRecordset* pRecordset);
  540. void AFXAPI DDX_FieldCBStringExact(CDataExchange* pDX, int nIDC, CString& value,
  541.     CDaoRecordset* pRecordset);
  542. void AFXAPI DDX_FieldScroll(CDataExchange* pDX, int nIDC, int& value,
  543.     CDaoRecordset* pRecordset);
  544. void AFXAPI DDX_FieldSlider(CDataExchange* pDX, int nIDC, int& value,
  545.     CDaoRecordset* pRecordset);
  546.  
  547. ////////////////////////////////////////////////////////////////////////
  548. // CDaoWorkspace - a DAO Workspace
  549.  
  550. class CDaoWorkspace : public CObject
  551. {
  552.     DECLARE_DYNAMIC(CDaoWorkspace)
  553.  
  554. // Constructors
  555. public:
  556.     CDaoWorkspace();
  557.  
  558.     virtual void Create(LPCTSTR lpszName, LPCTSTR lpszUserName,
  559.         LPCTSTR lpszPassword);
  560.     virtual void Append();
  561.  
  562.     virtual void Open(LPCTSTR lpszName = NULL);
  563.     virtual void Close();
  564.  
  565. // Attributes
  566. public:
  567.     DAOWorkspace* m_pDAOWorkspace;
  568.  
  569.     static CString PASCAL GetVersion();
  570.     static CString PASCAL GetIniPath();
  571.     static void PASCAL SetIniPath(LPCTSTR lpszRegistrySubKey);
  572.     static void PASCAL SetDefaultUser(LPCTSTR lpszDefaultUser);
  573.     static void PASCAL SetDefaultPassword(LPCTSTR lpszPassword);
  574.     static short PASCAL GetLoginTimeout();
  575.     static void PASCAL SetLoginTimeout(short nSeconds);
  576.  
  577.     CString GetName();
  578.     CString GetUserName();
  579.     void SetIsolateODBCTrans(BOOL bIsolateODBCTrans);
  580.     BOOL GetIsolateODBCTrans();
  581.  
  582.     BOOL IsOpen() const;
  583.  
  584. // Operations
  585. public:
  586.     void BeginTrans();
  587.     void CommitTrans();
  588.     void Rollback();
  589.  
  590.     static void PASCAL CompactDatabase(LPCTSTR lpszSrcName,
  591.         LPCTSTR lpszDestName, LPCTSTR lpszLocale = dbLangGeneral,
  592.         int nOptions = 0);
  593.     // Password parameter added late in dev cycle, new interface req'd
  594.     static void PASCAL CompactDatabase(LPCTSTR lpszSrcName,
  595.         LPCTSTR lpszDestName, LPCTSTR lpszLocale, int nOptions,
  596.         LPCTSTR lpszPassword);
  597.     static void PASCAL RepairDatabase(LPCTSTR lpszName);
  598.  
  599.     static void PASCAL Idle(int nAction = dbFreeLocks);
  600.  
  601.     short GetWorkspaceCount();
  602.     void GetWorkspaceInfo(int nIndex, CDaoWorkspaceInfo& wkspcinfo,
  603.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  604.     void GetWorkspaceInfo(LPCTSTR lpszName, CDaoWorkspaceInfo& wkspcinfo,
  605.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  606.  
  607.     short GetDatabaseCount();
  608.     void GetDatabaseInfo(int nIndex, CDaoDatabaseInfo& dbinfo,
  609.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  610.     void GetDatabaseInfo(LPCTSTR lpszName, CDaoDatabaseInfo& dbinfo,
  611.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  612.  
  613. // Overridables
  614. public:
  615.  
  616. // Implementation
  617. public:
  618.     virtual ~CDaoWorkspace();
  619.  
  620. #ifdef _DEBUG
  621.     virtual void AssertValid() const;
  622.     virtual void Dump(CDumpContext& dc) const;
  623. #endif
  624.  
  625.     DAOWorkspaces* m_pDAOWorkspaces;
  626.     DAODatabases* m_pDAODatabases;
  627.     int m_nStatus;
  628.  
  629.     CMapPtrToPtr m_mapDatabases;        // Map of all Open CDaoDatabases
  630.     BOOL IsNew() const;
  631.  
  632. protected:
  633.     BOOL m_bOpen;
  634.     BOOL m_bNew;
  635.  
  636.     static void AFX_CDECL InitializeEngine();
  637.  
  638.     void InitWorkspacesCollection();
  639.     void FillWorkspaceInfo(DAOWorkspace* pDAOWorkspace,
  640.         CDaoWorkspaceInfo& wsinfo, DWORD dwOptions);
  641.  
  642.     void InitDatabasesCollection();
  643.     void FillDatabaseInfo(DAODatabase* pDAODatabase,
  644.         CDaoDatabaseInfo& dbinfo, DWORD dwOptions);
  645.  
  646.     virtual void ThrowDaoException(int nError = NO_AFX_DAO_ERROR);
  647. };
  648.  
  649. ////////////////////////////////////////////////////////////////////////
  650. // CDaoException - DAO error trapping mechanism
  651. class CDaoException : public CException
  652. {
  653.     DECLARE_DYNAMIC(CDaoException)
  654.  
  655. // Constructors
  656. public:
  657.     CDaoException();
  658.  
  659. // Attributes
  660. public:
  661.     CDaoErrorInfo* m_pErrorInfo;
  662.  
  663.     SCODE m_scode;
  664.     int m_nAfxDaoError;     // DAO class extended error code
  665.  
  666. // Operations
  667. public:
  668.     short GetErrorCount();
  669.     void GetErrorInfo(int nIndex);
  670.  
  671. // Implementation
  672. public:
  673.     virtual ~CDaoException();
  674.  
  675.     DAOError* m_pDAOError;
  676.     DAOErrors* m_pDAOErrors;
  677.  
  678.     virtual BOOL GetErrorMessage(LPTSTR lpszError, UINT nMaxError,
  679.         PUINT pnHelpContext = NULL);
  680.  
  681. protected:
  682.     void InitErrorsCollection();
  683.     void FillErrorInfo();
  684. };
  685.  
  686. void AFXAPI AfxThrowDaoException(int nAfxDaoError = NO_AFX_DAO_ERROR,
  687.     SCODE scode = S_OK);
  688.  
  689.  
  690. ////////////////////////////////////////////////////////////////////////
  691. // CDaoDatabase - a DAO Database
  692.  
  693. class CDaoDatabase : public CObject
  694. {
  695.     DECLARE_DYNAMIC(CDaoDatabase)
  696.  
  697. // Constructors
  698. public:
  699.     CDaoDatabase(CDaoWorkspace* pWorkspace = NULL);
  700.  
  701.     virtual void Create(LPCTSTR lpszName,
  702.         LPCTSTR lpszLocale = dbLangGeneral, int dwOptions = 0);
  703.  
  704.     virtual void Open(LPCTSTR lpszName, BOOL bExclusive = FALSE,
  705.         BOOL bReadOnly = FALSE, LPCTSTR lpszConnect = _T(""));
  706.     virtual void Close();
  707.  
  708. // Attributes
  709. public:
  710.     CDaoWorkspace* m_pWorkspace;
  711.     DAODatabase* m_pDAODatabase;
  712.  
  713.     BOOL IsOpen() const;
  714.  
  715.     BOOL CanUpdate();
  716.     BOOL CanTransact();
  717.  
  718.     CString GetName();
  719.     CString GetConnect();
  720.  
  721.     CString GetVersion();
  722.     short GetQueryTimeout();
  723.     void SetQueryTimeout(short nSeconds);
  724.     long GetRecordsAffected();
  725.  
  726. // Operations
  727. public:
  728.     void Execute(LPCTSTR lpszSQL, int nOptions = dbFailOnError);
  729.  
  730.     void DeleteTableDef(LPCTSTR lpszName);
  731.     void DeleteQueryDef(LPCTSTR lpszName);
  732.  
  733.     void CreateRelation(LPCTSTR lpszName, LPCTSTR lpszTable,
  734.         LPCTSTR lpszForeignTable, long lAttributes,
  735.         LPCTSTR lpszField, LPCTSTR lpszForeignField);
  736.     void CreateRelation(CDaoRelationInfo& relinfo);
  737.     void DeleteRelation(LPCTSTR lpszName);
  738.  
  739.     short GetTableDefCount();
  740.     void GetTableDefInfo(int nIndex, CDaoTableDefInfo& tabledefinfo,
  741.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  742.     void GetTableDefInfo(LPCTSTR lpszName, CDaoTableDefInfo& tabledefinfo,
  743.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  744.  
  745.     short GetRelationCount();
  746.     void GetRelationInfo(int nIndex, CDaoRelationInfo& relinfo,
  747.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  748.     void GetRelationInfo(LPCTSTR lpszName, CDaoRelationInfo& relinfo,
  749.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  750.  
  751.     short GetQueryDefCount();
  752.     void GetQueryDefInfo(int nIndex, CDaoQueryDefInfo& querydefinfo,
  753.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  754.     void GetQueryDefInfo(LPCTSTR lpszName, CDaoQueryDefInfo& querydefinfo,
  755.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  756.  
  757. // Overridables
  758. public:
  759.  
  760. // Implementation
  761. public:
  762.     virtual ~CDaoDatabase();
  763.  
  764. #ifdef _DEBUG
  765.     virtual void AssertValid() const;
  766.     virtual void Dump(CDumpContext& dc) const;
  767. #endif
  768.  
  769.     DAOTableDefs* m_pDAOTableDefs;
  770.     DAORelations* m_pDAORelations;
  771.     DAOQueryDefs* m_pDAOQueryDefs;
  772.     DAORecordsets* m_pDAORecordsets;
  773.     int m_nStatus;
  774.  
  775.     CMapPtrToPtr m_mapTableDefs;        // Map of all Open CDaoTableDefs
  776.     CMapPtrToPtr m_mapQueryDefs;        // Map of all Open CDaoQueryDefs
  777.     CMapPtrToPtr m_mapRecordsets;       // Map of all Open CDaoRecordsets
  778.  
  779. protected:
  780.     BOOL m_bOpen;
  781.  
  782.     void InitWorkspace();
  783.     void InitTableDefsCollection();
  784.     void FillTableDefInfo(DAOTableDef* pDAOTableDef,
  785.         CDaoTableDefInfo& tabledefinfo, DWORD dwOptions);
  786.     void InitRelationsCollection();
  787.     void FillRelationInfo(DAORelation* pDAORelation,
  788.         CDaoRelationInfo& relinfo, DWORD dwOptions);
  789.     void InitQueryDefsCollection();
  790.     void FillQueryDefInfo(DAOQueryDef* pDAOQueryDef,
  791.         CDaoQueryDefInfo& querydefinfo, DWORD dwOptions);
  792.  
  793.     virtual void ThrowDaoException(int nError = NO_AFX_DAO_ERROR);
  794. };
  795.  
  796.  
  797. ////////////////////////////////////////////////////////////////////////
  798. // CDaoTableDef - a DAO TableDef
  799.  
  800. class CDaoTableDef : public CObject
  801. {
  802.     DECLARE_DYNAMIC(CDaoTableDef)
  803.  
  804. // Constructors
  805. public:
  806.     CDaoTableDef(CDaoDatabase* pDatabase);
  807.  
  808.     virtual void Create(LPCTSTR lpszName, long lAttributes = 0,
  809.         LPCTSTR lpszSrcTable = NULL, LPCTSTR lpszConnect = NULL);
  810.     virtual void Append();
  811.  
  812.     virtual void Open(LPCTSTR lpszName);
  813.     virtual void Close();
  814.  
  815. // Attributes
  816. public:
  817.     CDaoDatabase* m_pDatabase;
  818.     DAOTableDef* m_pDAOTableDef;
  819.  
  820.     BOOL IsOpen() const;
  821.     BOOL CanUpdate();
  822.  
  823.     void SetName(LPCTSTR lpszName);
  824.     CString GetName();
  825.     void SetSourceTableName(LPCTSTR lpszSrcTableName);
  826.     CString GetSourceTableName();
  827.     void SetConnect(LPCTSTR lpszConnect);
  828.     CString GetConnect();
  829.     void SetAttributes(long lAttributes);
  830.     long GetAttributes();
  831.     COleDateTime GetDateCreated();
  832.     COleDateTime GetDateLastUpdated();
  833.     void SetValidationRule(LPCTSTR lpszValidationRule);
  834.     CString GetValidationRule();
  835.     void SetValidationText(LPCTSTR lpszValidationText);
  836.     CString GetValidationText();
  837.     long GetRecordCount();
  838.  
  839. // Overridables
  840. public:
  841.  
  842. // Operations
  843. public:
  844.     void CreateField(LPCTSTR lpszName, short nType, long lSize,
  845.         long lAttributes = 0);
  846.     void CreateField(CDaoFieldInfo& fieldinfo);
  847.     void DeleteField(LPCTSTR lpszName);
  848.     void DeleteField(int nIndex);
  849.  
  850.     void CreateIndex(CDaoIndexInfo& indexinfo);
  851.     void DeleteIndex(LPCTSTR lpszName);
  852.     void DeleteIndex(int nIndex);
  853.  
  854.     short GetFieldCount();
  855.     void GetFieldInfo(int nIndex, CDaoFieldInfo& fieldinfo,
  856.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  857.     void GetFieldInfo(LPCTSTR lpszName, CDaoFieldInfo& fieldinfo,
  858.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  859.  
  860.     short GetIndexCount();
  861.     void GetIndexInfo(int nIndex, CDaoIndexInfo& indexinfo,
  862.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  863.     void GetIndexInfo(LPCTSTR lpszName, CDaoIndexInfo& indexinfo,
  864.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  865.  
  866.     void RefreshLink();
  867.  
  868. // Implementation
  869. public:
  870.     ~CDaoTableDef();
  871.  
  872. #ifdef _DEBUG
  873.     virtual void AssertValid() const;
  874.     virtual void Dump(CDumpContext& dc) const;
  875. #endif
  876.  
  877.     DAOFields* m_pDAOFields;
  878.     DAOIndexes* m_pDAOIndexes;
  879.  
  880. protected:
  881.     BOOL m_bOpen;
  882.     BOOL m_bNew;
  883.  
  884.     void InitFieldsCollection();
  885.     void InitIndexesCollection();
  886.  
  887.     virtual void ThrowDaoException(int nError = NO_AFX_DAO_ERROR);
  888. };
  889.  
  890.  
  891. ////////////////////////////////////////////////////////////////////////
  892. // CDaoQueryDef - a DAO QueryDef
  893.  
  894. class CDaoQueryDef : public CObject
  895. {
  896.     DECLARE_DYNAMIC(CDaoQueryDef)
  897.  
  898. // Constructors
  899. public:
  900.     CDaoQueryDef(CDaoDatabase* pDatabase);
  901.  
  902.     virtual void Create(LPCTSTR lpszName = NULL,
  903.         LPCTSTR lpszSQL = NULL);
  904.     virtual void Append();
  905.  
  906.     virtual void Open(LPCTSTR lpszName = NULL);
  907.     virtual void Close();
  908.  
  909. // Attributes
  910. public:
  911.     CDaoDatabase* m_pDatabase;
  912.     DAOQueryDef* m_pDAOQueryDef;
  913.  
  914.     BOOL CanUpdate();
  915.  
  916.     CString GetName();
  917.     void SetName(LPCTSTR lpszName);
  918.     CString GetSQL();
  919.     void SetSQL(LPCTSTR lpszSQL);
  920.     short GetType();
  921.     COleDateTime GetDateCreated();
  922.     COleDateTime GetDateLastUpdated();
  923.     CString GetConnect();
  924.     void SetConnect(LPCTSTR lpszConnect);
  925.     short GetODBCTimeout();
  926.     void SetODBCTimeout(short nODBCTimeout);
  927.     BOOL GetReturnsRecords();
  928.     void SetReturnsRecords(BOOL bReturnsRecords);
  929.     long GetRecordsAffected();
  930.  
  931.     BOOL IsOpen() const;
  932.  
  933. // Operations
  934. public:
  935.     virtual void Execute(int nOptions = dbFailOnError);
  936.  
  937.     virtual COleVariant GetParamValue(LPCTSTR lpszName);
  938.     virtual COleVariant GetParamValue(int nIndex);
  939.     virtual void SetParamValue(LPCTSTR lpszName,
  940.         const COleVariant& varValue);
  941.     virtual void SetParamValue(int nIndex,
  942.         const COleVariant& varValue);
  943.     void SetParamValueNull(LPCTSTR lpszName);
  944.     void SetParamValueNull(int nIndex);
  945.  
  946.     short GetFieldCount();
  947.     void GetFieldInfo(int nIndex, CDaoFieldInfo& fieldinfo,
  948.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  949.     void GetFieldInfo(LPCTSTR lpszName, CDaoFieldInfo& fieldinfo,
  950.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  951.  
  952.     short GetParameterCount();
  953.     void GetParameterInfo(int nIndex, CDaoParameterInfo& paraminfo,
  954.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  955.     void GetParameterInfo(LPCTSTR lpszName,
  956.         CDaoParameterInfo& paraminfo,
  957.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  958.  
  959. // Overridables
  960. public:
  961.  
  962. // Implementation
  963. public:
  964.     ~CDaoQueryDef();
  965.  
  966. #ifdef _DEBUG
  967.     virtual void AssertValid() const;
  968.     virtual void Dump(CDumpContext& dc) const;
  969. #endif
  970.  
  971.     DAOFields* m_pDAOFields;
  972.     DAOParameters* m_pDAOParameters;
  973.  
  974. protected:
  975.     BOOL m_bOpen;
  976.     BOOL m_bNew;
  977.  
  978.     void InitFieldsCollection();
  979.     void InitParametersCollection();
  980.     void FillParameterInfo(DAOParameter* pDAOParameter,
  981.         CDaoParameterInfo& paraminfo, DWORD dwInfoOptions);
  982.  
  983.     virtual void ThrowDaoException(int nError = NO_AFX_DAO_ERROR);
  984. };
  985.  
  986.  
  987. ////////////////////////////////////////////////////////////////////////
  988. // CDaoRecordset - the result of a query or base table browse
  989.  
  990. class CDaoRecordset : public CObject
  991. {
  992.     DECLARE_DYNAMIC(CDaoRecordset)
  993.  
  994. // Constructor
  995. public:
  996.     CDaoRecordset(CDaoDatabase* pDatabase = NULL);
  997.  
  998.     virtual void Open(int nOpenType = AFX_DAO_USE_DEFAULT_TYPE,
  999.         LPCTSTR lpszSQL = NULL, int nOptions = 0);
  1000.     virtual void Open(CDaoQueryDef* pQueryDef,
  1001.         int nOpenType = dbOpenDynaset, int nOptions = 0);
  1002.     virtual void Open(CDaoTableDef* pTableDef,
  1003.         int nOpenType = dbOpenTable, int nOptions = 0);
  1004.     virtual void Close();
  1005.  
  1006. // Attributes
  1007. public:
  1008.     CDaoDatabase* m_pDatabase;  // Source database for this result set
  1009.     DAORecordset* m_pDAORecordset;
  1010.  
  1011.     CString m_strFilter;    // Filter string used when constructing SQL
  1012.     CString m_strSort;      // Sort string used when constructing SQL
  1013.  
  1014.     int m_nFields;
  1015.     int m_nParams;
  1016.  
  1017.     BOOL m_bCheckCacheForDirtyFields;   // Switch for dirty field checking.
  1018.  
  1019.     BOOL CanUpdate() const;
  1020.     BOOL CanAppend() const;
  1021.     BOOL CanScroll() const;
  1022.     BOOL CanRestart();
  1023.     BOOL CanTransact();
  1024.     BOOL CanBookmark();
  1025.  
  1026.     BOOL IsOpen() const;
  1027.     BOOL IsBOF() const;
  1028.     BOOL IsEOF() const;
  1029.     BOOL IsDeleted() const;
  1030.  
  1031.     BOOL IsFieldDirty(void* pv);
  1032.     BOOL IsFieldNull(void* pv);
  1033.     BOOL IsFieldNullable(void* pv);
  1034.  
  1035.     CString GetName();
  1036.     short GetType();
  1037.     short GetEditMode();
  1038.     CString GetSQL() const;
  1039.  
  1040.     COleDateTime GetDateCreated();
  1041.     COleDateTime GetDateLastUpdated();
  1042.     COleVariant GetLastModifiedBookmark();
  1043.     CString GetValidationRule();
  1044.     CString GetValidationText();
  1045.     CString GetCurrentIndex();
  1046.     void SetCurrentIndex(LPCTSTR lpszIndex);
  1047.  
  1048.     long GetRecordCount();
  1049.  
  1050. // Operations
  1051. public:
  1052.     // Cursor operations
  1053.     void MoveNext();
  1054.     void MovePrev();
  1055.     void MoveFirst();
  1056.     void MoveLast();
  1057.     virtual void Move(long lRows);
  1058.  
  1059.     BOOL FindNext(LPCTSTR lpszFilter);
  1060.     BOOL FindPrev(LPCTSTR lpszFilter);
  1061.     BOOL FindFirst(LPCTSTR lpszFilter);
  1062.     BOOL FindLast(LPCTSTR lpszFilter);
  1063.     virtual BOOL Find(long lFindType, LPCTSTR lpszFilter);
  1064.  
  1065.     COleVariant GetBookmark();
  1066.     void SetBookmark(COleVariant varBookmark);
  1067.     long GetAbsolutePosition();
  1068.     void SetAbsolutePosition(long lPosition);
  1069.     float GetPercentPosition();
  1070.     void SetPercentPosition(float fPosition);
  1071.  
  1072.     // seek allowed on recordset opened as tables (max keys = 13)
  1073.     BOOL Seek(LPCTSTR lpszComparison, COleVariant* pKey1,
  1074.         COleVariant* pKey2 = NULL, COleVariant* pKey3 = NULL);
  1075.     BOOL Seek(LPCTSTR lpszComparison, COleVariant* pKeyArray, WORD nKeys);
  1076.  
  1077.     // edit buffer operations
  1078.     virtual void AddNew();
  1079.     virtual void Edit();
  1080.     virtual void Update();
  1081.     virtual void Delete();
  1082.     virtual void CancelUpdate();
  1083.  
  1084.     // field operations
  1085.     virtual void GetFieldValue(LPCTSTR lpszName, COleVariant& varValue);
  1086.     virtual void GetFieldValue(int nIndex, COleVariant& varValue);
  1087.     virtual void SetFieldValue(LPCTSTR lpszName,
  1088.         const COleVariant& varValue);
  1089.     virtual void SetFieldValue(int nIndex,
  1090.         const COleVariant& varValue);
  1091.     void SetFieldValue(int nIndex, LPCTSTR lpszValue);
  1092.     void SetFieldValue(LPCTSTR lpszName, LPCTSTR lpszValue);
  1093.     void SetFieldValueNull(LPCTSTR lpszName);
  1094.     void SetFieldValueNull(int nIndex);
  1095.  
  1096.     virtual COleVariant GetParamValue(LPCTSTR lpszName);
  1097.     virtual COleVariant GetParamValue(int nIndex);
  1098.     virtual void SetParamValue(LPCTSTR lpszName,
  1099.         const COleVariant& varValue);
  1100.     virtual void SetParamValue(int nIndex,
  1101.         const COleVariant& varValue);
  1102.     void SetParamValueNull(LPCTSTR lpszName);
  1103.     void SetParamValueNull(int nIndex);
  1104.  
  1105.     void SetFieldDirty(void* pv, BOOL bDirty = TRUE);
  1106.     void SetFieldNull(void* pv, BOOL bNull = TRUE);
  1107.  
  1108.     void SetLockingMode(BOOL bPessimistic);
  1109.     BOOL GetLockingMode();
  1110.  
  1111.     // Recordset operations
  1112.     virtual void Requery();
  1113.  
  1114.     // Jet's remote data caching operations
  1115.     void SetCacheStart(COleVariant varBookmark);
  1116.     COleVariant GetCacheStart();
  1117.     void SetCacheSize(long lSize);
  1118.     long GetCacheSize();
  1119.     void FillCache(long* pSize = NULL, COleVariant* pBookmark = NULL);
  1120.  
  1121.     short GetFieldCount();
  1122.     void GetFieldInfo(int nIndex, CDaoFieldInfo& fieldinfo,
  1123.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  1124.     void GetFieldInfo(LPCTSTR lpszName, CDaoFieldInfo& fieldinfo,
  1125.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  1126.  
  1127.     short GetIndexCount();
  1128.     void GetIndexInfo(int nIndex, CDaoIndexInfo& indexinfo,
  1129.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  1130.     void GetIndexInfo(LPCTSTR lpszName, CDaoIndexInfo& indexinfo,
  1131.         DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  1132.  
  1133. // Overridables
  1134. public:
  1135.     virtual CString GetDefaultDBName();
  1136.     virtual CString GetDefaultSQL();
  1137.  
  1138.     // for recordset field exchange
  1139.     virtual void DoFieldExchange(CDaoFieldExchange* pFX);
  1140.  
  1141. // Implementation
  1142. public:
  1143.     virtual ~CDaoRecordset();
  1144.  
  1145.     // Out-of-date functions kept for backward compatability
  1146.     virtual COleVariant GetFieldValue(LPCTSTR lpszName);
  1147.     virtual COleVariant GetFieldValue(int nIndex);
  1148.  
  1149. #ifdef _DEBUG
  1150.     virtual void AssertValid() const;
  1151.     virtual void Dump(CDumpContext& dc) const;
  1152. #endif
  1153.  
  1154.     CString m_strSQL;
  1155.  
  1156.     CDaoQueryDef* m_pQueryDef;  // Source query for this result set
  1157.     CDaoTableDef* m_pTableDef;
  1158.     ICDAORecordset* m_pICDAORecordsetGetRows;
  1159.     DAOFields* m_pDAOFields;
  1160.     DAOIndexes* m_pDAOIndexes;
  1161.  
  1162.     void SetCursorAttributes();
  1163.     void GetDataAndFixupNulls();
  1164.     DWORD GetFieldLength(int nFieldIndex);
  1165.  
  1166.     BOOL IsFieldStatusDirty(UINT nField);
  1167.     void SetDirtyFieldStatus(UINT nField);
  1168.     void ClearDirtyFieldStatus(UINT nField);
  1169.  
  1170.     BOOL IsFieldStatusNull(UINT nField);
  1171.     void SetNullFieldStatus(UINT nField);
  1172.     void ClearNullFieldStatus(UINT nField);
  1173.  
  1174.     BOOL IsFieldStatusNullable(UINT nField);
  1175.     void SetNullableFieldStatus(UINT nField);
  1176.  
  1177.     BOOL IsFieldStatusNullableKnown(UINT nField);
  1178.     void SetNullableKnownFieldStatus(UINT nField);
  1179.  
  1180.     void ClearFieldStatusFlags();
  1181.     BOOL IsMatch();
  1182.  
  1183.     DWORD m_cbFixedLengthFields;
  1184.     DAOCOLUMNBINDING* m_prgDaoColBindInfo;
  1185.     DWORD* m_pulColumnLengths;
  1186.     DAOFETCHROWS m_DaoFetchRows;
  1187.     BYTE* m_pbFieldFlags;
  1188.     BYTE* m_pbParamFlags;
  1189.  
  1190.     CMapPtrToPtr* m_pMapFieldCache;
  1191.     CMapPtrToPtr* m_pMapFieldIndex;
  1192.  
  1193.     static void AFX_CDECL StripBrackets(LPCTSTR lpszSrc, LPTSTR lpszDest);
  1194.  
  1195. protected:
  1196.     BOOL m_bOpen;
  1197.     int m_nStatus;
  1198.  
  1199.     BOOL m_bAppendable;
  1200.     BOOL m_bScrollable;
  1201.     BOOL m_bDeleted;
  1202.  
  1203.     int m_nOpenType;
  1204.     int m_nDefaultType;
  1205.     int m_nOptions;
  1206.  
  1207.     CString m_strRequerySQL;
  1208.     CString m_strRequeryFilter;
  1209.     CString m_strRequerySort;
  1210.  
  1211.     void BuildSQL();
  1212.     void AllocDatabase();
  1213.  
  1214.     // RFX Operation Cover Functions
  1215.     void BuildSelectList();
  1216.     void BuildParameterList();
  1217.     void BindFields();
  1218.     void BindParameters();
  1219.     void Fixup();
  1220.     void AllocCache();
  1221.     void StoreFields();
  1222.     void LoadFields();
  1223.     void FreeCache();
  1224.     void MarkForEdit();
  1225.     void MarkForAddNew();
  1226.     int GetFieldIndex(void* pv);
  1227.     virtual void SetDirtyFields();
  1228.  
  1229.     void InitFieldsCollection();
  1230.     void InitIndexesCollection();
  1231.  
  1232.     virtual void ThrowDaoException(int nError = NO_AFX_DAO_ERROR);
  1233.  
  1234.     friend class CDaoFieldExchange;
  1235.     friend class CDaoRecordView;
  1236. };
  1237.  
  1238. /////////////////////////////////////////////////////////////////////////////
  1239. // CDaoRecordView - form for viewing data records
  1240.  
  1241. #ifdef _AFXDLL
  1242. class CDaoRecordView : public CFormView
  1243. #else
  1244. class AFX_NOVTABLE CDaoRecordView : public CFormView
  1245. #endif
  1246. {
  1247.     DECLARE_DYNAMIC(CDaoRecordView)
  1248.  
  1249. // Construction
  1250. protected:  // must derive your own class
  1251.     CDaoRecordView(LPCTSTR lpszTemplateName);
  1252.     CDaoRecordView(UINT nIDTemplate);
  1253.  
  1254. // Attributes
  1255. public:
  1256.     virtual CDaoRecordset* OnGetRecordset() = 0;
  1257.  
  1258.     BOOL IsOnLastRecord();
  1259.     BOOL IsOnFirstRecord();
  1260.  
  1261. // Operations
  1262. public:
  1263.     virtual BOOL OnMove(UINT nIDMoveCommand);
  1264.  
  1265. // Implementation
  1266. public:
  1267.     virtual ~CDaoRecordView();
  1268. #ifdef _DEBUG
  1269.     virtual void AssertValid() const;
  1270.     virtual void Dump(CDumpContext& dc) const;
  1271. #endif
  1272.     virtual void OnInitialUpdate();
  1273.  
  1274. protected:
  1275.     int m_nStatus;
  1276.     COleVariant m_varBookmarkCurrent;
  1277.     COleVariant m_varBookmarkFirst;
  1278.     COleVariant m_varBookmarkLast;
  1279.  
  1280.     //{{AFX_MSG(CDaoRecordView)
  1281.     afx_msg void OnUpdateRecordFirst(CCmdUI* pCmdUI);
  1282.     afx_msg void OnUpdateRecordPrev(CCmdUI* pCmdUI);
  1283.     afx_msg void OnUpdateRecordNext(CCmdUI* pCmdUI);
  1284.     afx_msg void OnUpdateRecordLast(CCmdUI* pCmdUI);
  1285.     //}}AFX_MSG
  1286.     afx_msg void OnMove(int cx, int cy);
  1287.  
  1288.     DECLARE_MESSAGE_MAP()
  1289. };
  1290.  
  1291. /////////////////////////////////////////////////////////////////////////////
  1292. // DAODBEngine helpers - implementation specific and undocumented
  1293. void AFXAPI AfxDaoInit();
  1294. DAODBEngine* AFXAPI AfxDaoGetEngine();
  1295. void AFXAPI AfxDaoTerm();
  1296.  
  1297. /////////////////////////////////////////////////////////////////////////////
  1298. // Inline function declarations
  1299.  
  1300. #ifdef _AFX_PACKING
  1301. #pragma pack(pop)
  1302. #endif
  1303.  
  1304. #ifdef _AFX_ENABLE_INLINES
  1305. #define _AFXDAOCORE_INLINE AFX_INLINE
  1306. #define _AFXDAODFX_INLINE AFX_INLINE
  1307. #define _AFXDAOVIEW_INLINE AFX_INLINE
  1308. #include <afxdao.inl>
  1309. #undef _AFXDAOCORE_INLINE
  1310. #undef _AFXDAODFX_INLINE
  1311. #undef _AFXDAOVIEW_INLINE
  1312. #endif
  1313.  
  1314. #undef AFX_DATA
  1315. #define AFX_DATA
  1316.  
  1317. #ifdef _AFX_MINREBUILD
  1318. #pragma component(minrebuild, on)
  1319. #endif
  1320. #ifndef _AFX_FULLTYPEINFO
  1321. #pragma component(mintypeinfo, off)
  1322. #endif
  1323.  
  1324. #endif //__AFXDAO_H__
  1325.  
  1326. /////////////////////////////////////////////////////////////////////////////
  1327.