afxdao.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326
  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(MFC_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 MFC_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 MFC_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 MFC_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 MFC_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 MFC_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 MFC_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 MFC_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 MFC_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 MFC_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 MFC_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 MFC_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 MFC_DEBUG
  310. void AFXAPI AfxDaoTrace(SCODE scode, LPCSTR lpszDaoCall,
  311. LPCSTR lpszFile, int nLine);
  312. #endif
  313. #ifdef MFC_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 MFC_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 MFC_DEBUG
  386. CDumpContext* m_pdcDump;
  387. #endif //MFC_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. void AFXAPI DDX_FieldText(CDataExchange* pDX, int nIDC, LPTSTR pstrValue,
  443. int nMaxLen, CDaoRecordset* pRecordset);
  444. // special control types
  445. void AFXAPI DDX_FieldCheck(CDataExchange* pDX, int nIDC, int& value,
  446. CDaoRecordset* pRecordset);
  447. void AFXAPI DDX_FieldRadio(CDataExchange* pDX, int nIDC, int& value,
  448. CDaoRecordset* pRecordset);
  449. void AFXAPI DDX_FieldLBString(CDataExchange* pDX, int nIDC,
  450. CString& value, CDaoRecordset* pRecordset);
  451. void AFXAPI DDX_FieldCBString(CDataExchange* pDX, int nIDC,
  452. CString& value, CDaoRecordset* pRecordset);
  453. void AFXAPI DDX_FieldLBStringExact(CDataExchange* pDX, int nIDC,
  454. CString& value, CDaoRecordset* pRecordset);
  455. void AFXAPI DDX_FieldCBStringExact(CDataExchange* pDX, int nIDC,
  456. CString& value, CDaoRecordset* pRecordset);
  457. void AFXAPI DDX_FieldLBIndex(CDataExchange* pDX, int nIDC, int& index,
  458. CDaoRecordset* pRecordset);
  459. void AFXAPI DDX_FieldCBIndex(CDataExchange* pDX, int nIDC, int& index,
  460. CDaoRecordset* pRecordset);
  461. void AFXAPI DDX_FieldLBStringExact(CDataExchange* pDX, int nIDC, CString& value,
  462. CDaoRecordset* pRecordset);
  463. void AFXAPI DDX_FieldCBStringExact(CDataExchange* pDX, int nIDC, CString& value,
  464. CDaoRecordset* pRecordset);
  465. void AFXAPI DDX_FieldScroll(CDataExchange* pDX, int nIDC, int& value,
  466. CDaoRecordset* pRecordset);
  467. void AFXAPI DDX_FieldSlider(CDataExchange* pDX, int nIDC, int& value,
  468. CDaoRecordset* pRecordset);
  469. ////////////////////////////////////////////////////////////////////////
  470. // CDaoWorkspace - a DAO Workspace
  471. class CDaoWorkspace : public CObject
  472. {
  473. DECLARE_DYNAMIC(CDaoWorkspace)
  474. // Constructors
  475. public:
  476. CDaoWorkspace();
  477. virtual void Create(LPCTSTR lpszName, LPCTSTR lpszUserName,
  478. LPCTSTR lpszPassword);
  479. virtual void Append();
  480. virtual void Open(LPCTSTR lpszName = NULL);
  481. virtual void Close();
  482. // Attributes
  483. public:
  484. DAOWorkspace* m_pDAOWorkspace;
  485. static CString PASCAL GetVersion();
  486. static CString PASCAL GetIniPath();
  487. static void PASCAL SetIniPath(LPCTSTR lpszRegistrySubKey);
  488. static void PASCAL SetDefaultUser(LPCTSTR lpszDefaultUser);
  489. static void PASCAL SetDefaultPassword(LPCTSTR lpszPassword);
  490. static short PASCAL GetLoginTimeout();
  491. static void PASCAL SetLoginTimeout(short nSeconds);
  492. CString GetName();
  493. CString GetUserName();
  494. void SetIsolateODBCTrans(BOOL bIsolateODBCTrans);
  495. BOOL GetIsolateODBCTrans();
  496. BOOL IsOpen() const;
  497. // Operations
  498. public:
  499. void BeginTrans();
  500. void CommitTrans();
  501. void Rollback();
  502. static void PASCAL CompactDatabase(LPCTSTR lpszSrcName,
  503. LPCTSTR lpszDestName, LPCTSTR lpszLocale = dbLangGeneral,
  504. int nOptions = 0);
  505. // Password parameter added late in dev cycle, new interface req'd
  506. static void PASCAL CompactDatabase(LPCTSTR lpszSrcName,
  507. LPCTSTR lpszDestName, LPCTSTR lpszLocale, int nOptions,
  508. LPCTSTR lpszPassword);
  509. static void PASCAL RepairDatabase(LPCTSTR lpszName);
  510. static void PASCAL Idle(int nAction = dbFreeLocks);
  511. short GetWorkspaceCount();
  512. void GetWorkspaceInfo(int nIndex, CDaoWorkspaceInfo& wkspcinfo,
  513. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  514. void GetWorkspaceInfo(LPCTSTR lpszName, CDaoWorkspaceInfo& wkspcinfo,
  515. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  516. short GetDatabaseCount();
  517. void GetDatabaseInfo(int nIndex, CDaoDatabaseInfo& dbinfo,
  518. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  519. void GetDatabaseInfo(LPCTSTR lpszName, CDaoDatabaseInfo& dbinfo,
  520. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  521. // Overridables
  522. public:
  523. // Implementation
  524. public:
  525. virtual ~CDaoWorkspace();
  526. #ifdef MFC_DEBUG
  527. virtual void AssertValid() const;
  528. virtual void Dump(CDumpContext& dc) const;
  529. #endif
  530. DAOWorkspaces* m_pDAOWorkspaces;
  531. DAODatabases* m_pDAODatabases;
  532. int m_nStatus;
  533. CMapPtrToPtr m_mapDatabases; // Map of all Open CDaoDatabases
  534. BOOL IsNew() const;
  535. protected:
  536. BOOL m_bOpen;
  537. BOOL m_bNew;
  538. static void AFX_CDECL InitializeEngine();
  539. void InitWorkspacesCollection();
  540. void FillWorkspaceInfo(DAOWorkspace* pDAOWorkspace,
  541. CDaoWorkspaceInfo& wsinfo, DWORD dwOptions);
  542. void InitDatabasesCollection();
  543. void FillDatabaseInfo(DAODatabase* pDAODatabase,
  544. CDaoDatabaseInfo& dbinfo, DWORD dwOptions);
  545. virtual void ThrowDaoException(int nError = NO_AFX_DAO_ERROR);
  546. };
  547. ////////////////////////////////////////////////////////////////////////
  548. // CDaoException - DAO error trapping mechanism
  549. class CDaoException : public CException
  550. {
  551. DECLARE_DYNAMIC(CDaoException)
  552. // Constructors
  553. public:
  554. CDaoException();
  555. // Attributes
  556. public:
  557. CDaoErrorInfo* m_pErrorInfo;
  558. SCODE m_scode;
  559. int m_nAfxDaoError; // DAO class extended error code
  560. // Operations
  561. public:
  562. short GetErrorCount();
  563. void GetErrorInfo(int nIndex);
  564. // Implementation
  565. public:
  566. virtual ~CDaoException();
  567. DAOError* m_pDAOError;
  568. DAOErrors* m_pDAOErrors;
  569. virtual BOOL GetErrorMessage(LPTSTR lpszError, UINT nMaxError,
  570. PUINT pnHelpContext = NULL);
  571. protected:
  572. void InitErrorsCollection();
  573. void FillErrorInfo();
  574. };
  575. void AFXAPI AfxThrowDaoException(int nAfxDaoError = NO_AFX_DAO_ERROR,
  576. SCODE scode = S_OK);
  577. ////////////////////////////////////////////////////////////////////////
  578. // CDaoDatabase - a DAO Database
  579. class CDaoDatabase : public CObject
  580. {
  581. DECLARE_DYNAMIC(CDaoDatabase)
  582. // Constructors
  583. public:
  584. CDaoDatabase(CDaoWorkspace* pWorkspace = NULL);
  585. virtual void Create(LPCTSTR lpszName,
  586. LPCTSTR lpszLocale = dbLangGeneral, int dwOptions = 0);
  587. virtual void Open(LPCTSTR lpszName, BOOL bExclusive = FALSE,
  588. BOOL bReadOnly = FALSE, LPCTSTR lpszConnect = _T(""));
  589. virtual void Close();
  590. // Attributes
  591. public:
  592. CDaoWorkspace* m_pWorkspace;
  593. DAODatabase* m_pDAODatabase;
  594. BOOL IsOpen() const;
  595. BOOL CanUpdate();
  596. BOOL CanTransact();
  597. CString GetName();
  598. CString GetConnect();
  599. CString GetVersion();
  600. short GetQueryTimeout();
  601. void SetQueryTimeout(short nSeconds);
  602. long GetRecordsAffected();
  603. // Operations
  604. public:
  605. void Execute(LPCTSTR lpszSQL, int nOptions = dbFailOnError);
  606. void DeleteTableDef(LPCTSTR lpszName);
  607. void DeleteQueryDef(LPCTSTR lpszName);
  608. void CreateRelation(LPCTSTR lpszName, LPCTSTR lpszTable,
  609. LPCTSTR lpszForeignTable, long lAttributes,
  610. LPCTSTR lpszField, LPCTSTR lpszForeignField);
  611. void CreateRelation(CDaoRelationInfo& relinfo);
  612. void DeleteRelation(LPCTSTR lpszName);
  613. short GetTableDefCount();
  614. void GetTableDefInfo(int nIndex, CDaoTableDefInfo& tabledefinfo,
  615. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  616. void GetTableDefInfo(LPCTSTR lpszName, CDaoTableDefInfo& tabledefinfo,
  617. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  618. short GetRelationCount();
  619. void GetRelationInfo(int nIndex, CDaoRelationInfo& relinfo,
  620. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  621. void GetRelationInfo(LPCTSTR lpszName, CDaoRelationInfo& relinfo,
  622. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  623. short GetQueryDefCount();
  624. void GetQueryDefInfo(int nIndex, CDaoQueryDefInfo& querydefinfo,
  625. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  626. void GetQueryDefInfo(LPCTSTR lpszName, CDaoQueryDefInfo& querydefinfo,
  627. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  628. // Overridables
  629. public:
  630. // Implementation
  631. public:
  632. virtual ~CDaoDatabase();
  633. #ifdef MFC_DEBUG
  634. virtual void AssertValid() const;
  635. virtual void Dump(CDumpContext& dc) const;
  636. #endif
  637. DAOTableDefs* m_pDAOTableDefs;
  638. DAORelations* m_pDAORelations;
  639. DAOQueryDefs* m_pDAOQueryDefs;
  640. DAORecordsets* m_pDAORecordsets;
  641. int m_nStatus;
  642. CMapPtrToPtr m_mapTableDefs; // Map of all Open CDaoTableDefs
  643. CMapPtrToPtr m_mapQueryDefs; // Map of all Open CDaoQueryDefs
  644. CMapPtrToPtr m_mapRecordsets; // Map of all Open CDaoRecordsets
  645. protected:
  646. BOOL m_bOpen;
  647. void InitWorkspace();
  648. void InitTableDefsCollection();
  649. void FillTableDefInfo(DAOTableDef* pDAOTableDef,
  650. CDaoTableDefInfo& tabledefinfo, DWORD dwOptions);
  651. void InitRelationsCollection();
  652. void FillRelationInfo(DAORelation* pDAORelation,
  653. CDaoRelationInfo& relinfo, DWORD dwOptions);
  654. void InitQueryDefsCollection();
  655. void FillQueryDefInfo(DAOQueryDef* pDAOQueryDef,
  656. CDaoQueryDefInfo& querydefinfo, DWORD dwOptions);
  657. virtual void ThrowDaoException(int nError = NO_AFX_DAO_ERROR);
  658. };
  659. ////////////////////////////////////////////////////////////////////////
  660. // CDaoTableDef - a DAO TableDef
  661. class CDaoTableDef : public CObject
  662. {
  663. DECLARE_DYNAMIC(CDaoTableDef)
  664. // Constructors
  665. public:
  666. CDaoTableDef(CDaoDatabase* pDatabase);
  667. virtual void Create(LPCTSTR lpszName, long lAttributes = 0,
  668. LPCTSTR lpszSrcTable = NULL, LPCTSTR lpszConnect = NULL);
  669. virtual void Append();
  670. virtual void Open(LPCTSTR lpszName);
  671. virtual void Close();
  672. // Attributes
  673. public:
  674. CDaoDatabase* m_pDatabase;
  675. DAOTableDef* m_pDAOTableDef;
  676. BOOL IsOpen() const;
  677. BOOL CanUpdate();
  678. void SetName(LPCTSTR lpszName);
  679. CString GetName();
  680. void SetSourceTableName(LPCTSTR lpszSrcTableName);
  681. CString GetSourceTableName();
  682. void SetConnect(LPCTSTR lpszConnect);
  683. CString GetConnect();
  684. void SetAttributes(long lAttributes);
  685. long GetAttributes();
  686. COleDateTime GetDateCreated();
  687. COleDateTime GetDateLastUpdated();
  688. void SetValidationRule(LPCTSTR lpszValidationRule);
  689. CString GetValidationRule();
  690. void SetValidationText(LPCTSTR lpszValidationText);
  691. CString GetValidationText();
  692. long GetRecordCount();
  693. // Overridables
  694. public:
  695. // Operations
  696. public:
  697. void CreateField(LPCTSTR lpszName, short nType, long lSize,
  698. long lAttributes = 0);
  699. void CreateField(CDaoFieldInfo& fieldinfo);
  700. void DeleteField(LPCTSTR lpszName);
  701. void DeleteField(int nIndex);
  702. void CreateIndex(CDaoIndexInfo& indexinfo);
  703. void DeleteIndex(LPCTSTR lpszName);
  704. void DeleteIndex(int nIndex);
  705. short GetFieldCount();
  706. void GetFieldInfo(int nIndex, CDaoFieldInfo& fieldinfo,
  707. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  708. void GetFieldInfo(LPCTSTR lpszName, CDaoFieldInfo& fieldinfo,
  709. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  710. short GetIndexCount();
  711. void GetIndexInfo(int nIndex, CDaoIndexInfo& indexinfo,
  712. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  713. void GetIndexInfo(LPCTSTR lpszName, CDaoIndexInfo& indexinfo,
  714. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  715. void RefreshLink();
  716. // Implementation
  717. public:
  718. ~CDaoTableDef();
  719. #ifdef MFC_DEBUG
  720. virtual void AssertValid() const;
  721. virtual void Dump(CDumpContext& dc) const;
  722. #endif
  723. DAOFields* m_pDAOFields;
  724. DAOIndexes* m_pDAOIndexes;
  725. protected:
  726. BOOL m_bOpen;
  727. BOOL m_bNew;
  728. void InitFieldsCollection();
  729. void InitIndexesCollection();
  730. virtual void ThrowDaoException(int nError = NO_AFX_DAO_ERROR);
  731. };
  732. ////////////////////////////////////////////////////////////////////////
  733. // CDaoQueryDef - a DAO QueryDef
  734. class CDaoQueryDef : public CObject
  735. {
  736. DECLARE_DYNAMIC(CDaoQueryDef)
  737. // Constructors
  738. public:
  739. CDaoQueryDef(CDaoDatabase* pDatabase);
  740. virtual void Create(LPCTSTR lpszName = NULL,
  741. LPCTSTR lpszSQL = NULL);
  742. virtual void Append();
  743. virtual void Open(LPCTSTR lpszName = NULL);
  744. virtual void Close();
  745. // Attributes
  746. public:
  747. CDaoDatabase* m_pDatabase;
  748. DAOQueryDef* m_pDAOQueryDef;
  749. BOOL CanUpdate();
  750. CString GetName();
  751. void SetName(LPCTSTR lpszName);
  752. CString GetSQL();
  753. void SetSQL(LPCTSTR lpszSQL);
  754. short GetType();
  755. COleDateTime GetDateCreated();
  756. COleDateTime GetDateLastUpdated();
  757. CString GetConnect();
  758. void SetConnect(LPCTSTR lpszConnect);
  759. short GetODBCTimeout();
  760. void SetODBCTimeout(short nODBCTimeout);
  761. BOOL GetReturnsRecords();
  762. void SetReturnsRecords(BOOL bReturnsRecords);
  763. long GetRecordsAffected();
  764. BOOL IsOpen() const;
  765. // Operations
  766. public:
  767. virtual void Execute(int nOptions = dbFailOnError);
  768. virtual COleVariant GetParamValue(LPCTSTR lpszName);
  769. virtual COleVariant GetParamValue(int nIndex);
  770. virtual void SetParamValue(LPCTSTR lpszName,
  771. const COleVariant& varValue);
  772. virtual void SetParamValue(int nIndex,
  773. const COleVariant& varValue);
  774. void SetParamValueNull(LPCTSTR lpszName);
  775. void SetParamValueNull(int nIndex);
  776. short GetFieldCount();
  777. void GetFieldInfo(int nIndex, CDaoFieldInfo& fieldinfo,
  778. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  779. void GetFieldInfo(LPCTSTR lpszName, CDaoFieldInfo& fieldinfo,
  780. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  781. short GetParameterCount();
  782. void GetParameterInfo(int nIndex, CDaoParameterInfo& paraminfo,
  783. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  784. void GetParameterInfo(LPCTSTR lpszName,
  785. CDaoParameterInfo& paraminfo,
  786. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  787. // Overridables
  788. public:
  789. // Implementation
  790. public:
  791. ~CDaoQueryDef();
  792. #ifdef MFC_DEBUG
  793. virtual void AssertValid() const;
  794. virtual void Dump(CDumpContext& dc) const;
  795. #endif
  796. DAOFields* m_pDAOFields;
  797. DAOParameters* m_pDAOParameters;
  798. protected:
  799. BOOL m_bOpen;
  800. BOOL m_bNew;
  801. void InitFieldsCollection();
  802. void InitParametersCollection();
  803. void FillParameterInfo(DAOParameter* pDAOParameter,
  804. CDaoParameterInfo& paraminfo, DWORD dwInfoOptions);
  805. virtual void ThrowDaoException(int nError = NO_AFX_DAO_ERROR);
  806. };
  807. ////////////////////////////////////////////////////////////////////////
  808. // CDaoRecordset - the result of a query or base table browse
  809. class CDaoRecordset : public CObject
  810. {
  811. DECLARE_DYNAMIC(CDaoRecordset)
  812. // Constructor
  813. public:
  814. CDaoRecordset(CDaoDatabase* pDatabase = NULL);
  815. virtual void Open(int nOpenType = AFX_DAO_USE_DEFAULT_TYPE,
  816. LPCTSTR lpszSQL = NULL, int nOptions = 0);
  817. virtual void Open(CDaoQueryDef* pQueryDef,
  818. int nOpenType = dbOpenDynaset, int nOptions = 0);
  819. virtual void Open(CDaoTableDef* pTableDef,
  820. int nOpenType = dbOpenTable, int nOptions = 0);
  821. virtual void Close();
  822. // Attributes
  823. public:
  824. CDaoDatabase* m_pDatabase; // Source database for this result set
  825. DAORecordset* m_pDAORecordset;
  826. CString m_strFilter; // Filter string used when constructing SQL
  827. CString m_strSort; // Sort string used when constructing SQL
  828. int m_nFields;
  829. int m_nParams;
  830. BOOL m_bCheckCacheForDirtyFields; // Switch for dirty field checking.
  831. BOOL CanUpdate() const;
  832. BOOL CanAppend() const;
  833. BOOL CanScroll() const;
  834. BOOL CanRestart();
  835. BOOL CanTransact();
  836. BOOL CanBookmark();
  837. BOOL IsOpen() const;
  838. BOOL IsBOF() const;
  839. BOOL IsEOF() const;
  840. BOOL IsDeleted() const;
  841. BOOL IsFieldDirty(void* pv);
  842. BOOL IsFieldNull(void* pv);
  843. BOOL IsFieldNullable(void* pv);
  844. CString GetName();
  845. short GetType();
  846. short GetEditMode();
  847. CString GetSQL() const;
  848. COleDateTime GetDateCreated();
  849. COleDateTime GetDateLastUpdated();
  850. COleVariant GetLastModifiedBookmark();
  851. CString GetValidationRule();
  852. CString GetValidationText();
  853. CString GetCurrentIndex();
  854. void SetCurrentIndex(LPCTSTR lpszIndex);
  855. long GetRecordCount();
  856. // Operations
  857. public:
  858. // Cursor operations
  859. void MoveNext();
  860. void MovePrev();
  861. void MoveFirst();
  862. void MoveLast();
  863. virtual void Move(long lRows);
  864. BOOL FindNext(LPCTSTR lpszFilter);
  865. BOOL FindPrev(LPCTSTR lpszFilter);
  866. BOOL FindFirst(LPCTSTR lpszFilter);
  867. BOOL FindLast(LPCTSTR lpszFilter);
  868. virtual BOOL Find(long lFindType, LPCTSTR lpszFilter);
  869. COleVariant GetBookmark();
  870. void SetBookmark(COleVariant varBookmark);
  871. long GetAbsolutePosition();
  872. void SetAbsolutePosition(long lPosition);
  873. float GetPercentPosition();
  874. void SetPercentPosition(float fPosition);
  875. // seek allowed on recordset opened as tables (max keys = 13)
  876. BOOL Seek(LPCTSTR lpszComparison, COleVariant* pKey1,
  877. COleVariant* pKey2 = NULL, COleVariant* pKey3 = NULL);
  878. BOOL Seek(LPCTSTR lpszComparison, COleVariant* pKeyArray, WORD nKeys);
  879. // edit buffer operations
  880. virtual void AddNew();
  881. virtual void Edit();
  882. virtual void Update();
  883. virtual void Delete();
  884. virtual void CancelUpdate();
  885. // field operations
  886. virtual void GetFieldValue(LPCTSTR lpszName, COleVariant& varValue);
  887. virtual void GetFieldValue(int nIndex, COleVariant& varValue);
  888. virtual void SetFieldValue(LPCTSTR lpszName,
  889. const COleVariant& varValue);
  890. virtual void SetFieldValue(int nIndex,
  891. const COleVariant& varValue);
  892. void SetFieldValue(int nIndex, LPCTSTR lpszValue);
  893. void SetFieldValue(LPCTSTR lpszName, LPCTSTR lpszValue);
  894. void SetFieldValueNull(LPCTSTR lpszName);
  895. void SetFieldValueNull(int nIndex);
  896. virtual COleVariant GetParamValue(LPCTSTR lpszName);
  897. virtual COleVariant GetParamValue(int nIndex);
  898. virtual void SetParamValue(LPCTSTR lpszName,
  899. const COleVariant& varValue);
  900. virtual void SetParamValue(int nIndex,
  901. const COleVariant& varValue);
  902. void SetParamValueNull(LPCTSTR lpszName);
  903. void SetParamValueNull(int nIndex);
  904. void SetFieldDirty(void* pv, BOOL bDirty = TRUE);
  905. void SetFieldNull(void* pv, BOOL bNull = TRUE);
  906. void SetLockingMode(BOOL bPessimistic);
  907. BOOL GetLockingMode();
  908. // Recordset operations
  909. virtual void Requery();
  910. // Jet's remote data caching operations
  911. void SetCacheStart(COleVariant varBookmark);
  912. COleVariant GetCacheStart();
  913. void SetCacheSize(long lSize);
  914. long GetCacheSize();
  915. void FillCache(long* pSize = NULL, COleVariant* pBookmark = NULL);
  916. short GetFieldCount();
  917. void GetFieldInfo(int nIndex, CDaoFieldInfo& fieldinfo,
  918. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  919. void GetFieldInfo(LPCTSTR lpszName, CDaoFieldInfo& fieldinfo,
  920. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  921. short GetIndexCount();
  922. void GetIndexInfo(int nIndex, CDaoIndexInfo& indexinfo,
  923. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  924. void GetIndexInfo(LPCTSTR lpszName, CDaoIndexInfo& indexinfo,
  925. DWORD dwInfoOptions = AFX_DAO_PRIMARY_INFO);
  926. // Overridables
  927. public:
  928. virtual CString GetDefaultDBName();
  929. virtual CString GetDefaultSQL();
  930. // for recordset field exchange
  931. virtual void DoFieldExchange(CDaoFieldExchange* pFX);
  932. // Implementation
  933. public:
  934. virtual ~CDaoRecordset();
  935. // Out-of-date functions kept for backward compatability
  936. virtual COleVariant GetFieldValue(LPCTSTR lpszName);
  937. virtual COleVariant GetFieldValue(int nIndex);
  938. #ifdef MFC_DEBUG
  939. virtual void AssertValid() const;
  940. virtual void Dump(CDumpContext& dc) const;
  941. #endif
  942. CString m_strSQL;
  943. CDaoQueryDef* m_pQueryDef; // Source query for this result set
  944. CDaoTableDef* m_pTableDef;
  945. ICDAORecordset* m_pICDAORecordsetGetRows;
  946. DAOFields* m_pDAOFields;
  947. DAOIndexes* m_pDAOIndexes;
  948. void SetCursorAttributes();
  949. void GetDataAndFixupNulls();
  950. DWORD GetFieldLength(int nFieldIndex);
  951. BOOL IsFieldStatusDirty(UINT nField);
  952. void SetDirtyFieldStatus(UINT nField);
  953. void ClearDirtyFieldStatus(UINT nField);
  954. BOOL IsFieldStatusNull(UINT nField);
  955. void SetNullFieldStatus(UINT nField);
  956. void ClearNullFieldStatus(UINT nField);
  957. BOOL IsFieldStatusNullable(UINT nField);
  958. void SetNullableFieldStatus(UINT nField);
  959. BOOL IsFieldStatusNullableKnown(UINT nField);
  960. void SetNullableKnownFieldStatus(UINT nField);
  961. void ClearFieldStatusFlags();
  962. BOOL IsMatch();
  963. DWORD m_cbFixedLengthFields;
  964. DAOCOLUMNBINDING* m_prgDaoColBindInfo;
  965. DWORD* m_pulColumnLengths;
  966. DAOFETCHROWS m_DaoFetchRows;
  967. BYTE* m_pbFieldFlags;
  968. BYTE* m_pbParamFlags;
  969. CMapPtrToPtr* m_pMapFieldCache;
  970. CMapPtrToPtr* m_pMapFieldIndex;
  971. static void AFX_CDECL StripBrackets(LPCTSTR lpszSrc, LPTSTR lpszDest);
  972. protected:
  973. BOOL m_bOpen;
  974. int m_nStatus;
  975. BOOL m_bAppendable;
  976. BOOL m_bScrollable;
  977. BOOL m_bDeleted;
  978. int m_nOpenType;
  979. int m_nDefaultType;
  980. int m_nOptions;
  981. CString m_strRequerySQL;
  982. CString m_strRequeryFilter;
  983. CString m_strRequerySort;
  984. void BuildSQL();
  985. void AllocDatabase();
  986. // RFX Operation Cover Functions
  987. void BuildSelectList();
  988. void BuildParameterList();
  989. void BindFields();
  990. void BindParameters();
  991. void Fixup();
  992. void AllocCache();
  993. void StoreFields();
  994. void LoadFields();
  995. void FreeCache();
  996. void MarkForEdit();
  997. void MarkForAddNew();
  998. int GetFieldIndex(void* pv);
  999. virtual void SetDirtyFields();
  1000. void InitFieldsCollection();
  1001. void InitIndexesCollection();
  1002. virtual void ThrowDaoException(int nError = NO_AFX_DAO_ERROR);
  1003. friend class CDaoFieldExchange;
  1004. friend class CDaoRecordView;
  1005. };
  1006. /////////////////////////////////////////////////////////////////////////////
  1007. // CDaoRecordView - form for viewing data records
  1008. #ifdef _AFXDLL
  1009. class CDaoRecordView : public CFormView
  1010. #else
  1011. class AFX_NOVTABLE CDaoRecordView : public CFormView
  1012. #endif
  1013. {
  1014. DECLARE_DYNAMIC(CDaoRecordView)
  1015. // Construction
  1016. protected: // must derive your own class
  1017. CDaoRecordView(LPCTSTR lpszTemplateName);
  1018. CDaoRecordView(UINT nIDTemplate);
  1019. // Attributes
  1020. public:
  1021. virtual CDaoRecordset* OnGetRecordset() = 0;
  1022. BOOL IsOnLastRecord();
  1023. BOOL IsOnFirstRecord();
  1024. // Operations
  1025. public:
  1026. virtual BOOL OnMove(UINT nIDMoveCommand);
  1027. // Implementation
  1028. public:
  1029. virtual ~CDaoRecordView();
  1030. #ifdef MFC_DEBUG
  1031. virtual void AssertValid() const;
  1032. virtual void Dump(CDumpContext& dc) const;
  1033. #endif
  1034. virtual void OnInitialUpdate();
  1035. protected:
  1036. int m_nStatus;
  1037. COleVariant m_varBookmarkCurrent;
  1038. COleVariant m_varBookmarkFirst;
  1039. COleVariant m_varBookmarkLast;
  1040. //{{AFX_MSG(CDaoRecordView)
  1041. afx_msg void OnUpdateRecordFirst(CCmdUI* pCmdUI);
  1042. afx_msg void OnUpdateRecordPrev(CCmdUI* pCmdUI);
  1043. afx_msg void OnUpdateRecordNext(CCmdUI* pCmdUI);
  1044. afx_msg void OnUpdateRecordLast(CCmdUI* pCmdUI);
  1045. //}}AFX_MSG
  1046. afx_msg void OnMove(int cx, int cy);
  1047. DECLARE_MESSAGE_MAP()
  1048. };
  1049. /////////////////////////////////////////////////////////////////////////////
  1050. // DAODBEngine helpers - implementation specific and undocumented
  1051. void AFXAPI AfxDaoInit();
  1052. DAODBEngine* AFXAPI AfxDaoGetEngine();
  1053. void AFXAPI AfxDaoTerm();
  1054. /////////////////////////////////////////////////////////////////////////////
  1055. // Inline function declarations
  1056. #ifdef _AFX_PACKING
  1057. #pragma pack(pop)
  1058. #endif
  1059. #ifdef _AFX_ENABLE_INLINES
  1060. #define _AFXDAOCORE_INLINE AFX_INLINE
  1061. #define _AFXDAODFX_INLINE AFX_INLINE
  1062. #define _AFXDAOVIEW_INLINE AFX_INLINE
  1063. #include <afxdao.inl>
  1064. #undef _AFXDAOCORE_INLINE
  1065. #undef _AFXDAODFX_INLINE
  1066. #undef _AFXDAOVIEW_INLINE
  1067. #endif
  1068. #undef AFX_DATA
  1069. #define AFX_DATA
  1070. #ifdef _AFX_MINREBUILD
  1071. #pragma component(minrebuild, on)
  1072. #endif
  1073. #ifndef _AFX_FULLTYPEINFO
  1074. #pragma component(mintypeinfo, off)
  1075. #endif
  1076. #endif //__AFXDAO_H__
  1077. /////////////////////////////////////////////////////////////////////////////