Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1335 lines
37 KiB

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