?? afxdao.h
字號:
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1998 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#ifndef __AFXDAO_H
#define __AFXDAO_H
#ifdef _AFX_NO_DAO_SUPPORT
#error DAO Database classes not supported in this library variant.
#endif
#ifndef __AFXDISP_H__
#include <afxdisp.h> // Must include this before dao headers
#endif
#ifndef _DBDAOINT_H_
#include <dbdaoint.h>
#endif
#ifndef _DAOGETRW_H_
#include <daogetrw.h>
#endif
#ifndef _DBDAOID_H_
#include <dbdaoid.h>
#endif
#ifndef _DBDAOERR_H_
#include <dbdaoerr.h>
#endif
#ifndef __AFXDB__H__
#include <afxdb_.h> // shared header with ODBC database classes
#endif
#ifndef __AFXEXT_H__
#include <afxext.h> // for CFormView
#endif
#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, off)
#endif
#ifndef _AFX_FULLTYPEINFO
#pragma component(mintypeinfo, on)
#endif
#ifndef _AFX_NOFORCE_LIBS
/////////////////////////////////////////////////////////////////////////////
// Win32 libraries
#ifdef _AFXDLL
#if defined(_DEBUG) && !defined(_AFX_MONOLITHIC)
#ifndef _UNICODE
#pragma comment(lib, "mfco42d.lib")
#pragma comment(lib, "mfcd42d.lib")
#else
#pragma comment(lib, "mfco42ud.lib")
#pragma comment(lib, "mfcd42ud.lib")
#endif
#endif
#endif
#pragma comment(lib, "daouuid.lib")
#endif //!_AFX_NOFORCE_LIBS
#ifdef _AFX_PACKING
#pragma pack(push, _AFX_PACKING)
#endif
////////////////////////////////////////////////////////////////////////
// AFXDAO - MFC Database support using DAO
// Classes declared in this file
// CException
class CDaoException; // DAO error/exception handling
// CObject
class CDaoRecordView;
class CDaoWorkspace; // DAO engine/transaction/security manager
class CDaoDatabase; // DAO database manager
class CDaoRecordset; // DAO result set manager
class CDaoTableDef; // DAO base table manager
class CDaoQueryDef; // DAO query manager
// Non-CObject classes
class CDaoFieldExchange;
struct CDaoFieldCache;
struct CDaoErrorInfo;
struct CDaoWorkspaceInfo;
struct CDaoDatabaseInfo;
struct CDaoTableDefInfo;
struct CDaoFieldInfo;
struct CDaoIndexInfo;
struct CDaoRelationInfo;
struct CDaoQueryDefInfo;
struct CDaoParameterInfo;
/////////////////////////////////////////////////////////////////////////////
// AFXDLL support
#undef AFX_DATA
#define AFX_DATA AFX_DB_DATA
////////////////////////////////////////////////////////////////////////
// Data caching structures
struct CDaoFieldCache
{
void* m_pvData; // Pointer to cached data of any supported type.
BYTE m_nStatus; // (NULL) status cache.
BYTE m_nDataType; // Type of data cached.
};
////////////////////////////////////////////////////////////////////////
// Info structures
struct CDaoErrorInfo
{
// Attributes
long m_lErrorCode;
CString m_strSource;
CString m_strDescription;
CString m_strHelpFile;
long m_lHelpContext;
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
};
struct CDaoWorkspaceInfo
{
// Attributes
CString m_strName; // Primary
CString m_strUserName; // Secondary
BOOL m_bIsolateODBCTrans; // All
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
};
struct CDaoDatabaseInfo
{
// Attributes
CString m_strName; // Primary
BOOL m_bUpdatable; // Primary
BOOL m_bTransactions; // Primary
CString m_strVersion; // Secondary
long m_lCollatingOrder; // Secondary
short m_nQueryTimeout; // Secondary
CString m_strConnect; // All
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
};
struct CDaoTableDefInfo
{
// Attributes
CString m_strName; // Primary
BOOL m_bUpdatable; // Primary
long m_lAttributes; // Primary
COleDateTime m_dateCreated; // Secondary
COleDateTime m_dateLastUpdated; // Secondary
CString m_strSrcTableName; // Secondary
CString m_strConnect; // Secondary
CString m_strValidationRule; // All
CString m_strValidationText; // All
long m_lRecordCount; // All
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
};
struct CDaoFieldInfo
{
// Attributes
CString m_strName; // Primary
short m_nType; // Primary
long m_lSize; // Primary
long m_lAttributes; // Primary
short m_nOrdinalPosition; // Secondary
BOOL m_bRequired; // Secondary
BOOL m_bAllowZeroLength; // Secondary
long m_lCollatingOrder; // Secondary
CString m_strForeignName; // Secondary
CString m_strSourceField; // Secondary
CString m_strSourceTable; // Secondary
CString m_strValidationRule; // All
CString m_strValidationText; // All
CString m_strDefaultValue; // All
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
};
struct CDaoIndexFieldInfo
{
// Attributes
CString m_strName; // Primary
BOOL m_bDescending; // Primary
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
};
struct CDaoIndexInfo
{
// Constructors
CDaoIndexInfo();
// Attributes
CString m_strName; // Primary
CDaoIndexFieldInfo* m_pFieldInfos; // Primary
short m_nFields; // Primary
BOOL m_bPrimary; // Secondary
BOOL m_bUnique; // Secondary
BOOL m_bClustered; // Secondary
BOOL m_bIgnoreNulls; // Secondary
BOOL m_bRequired; // Secondary
BOOL m_bForeign; // Secondary
long m_lDistinctCount; // All
// Implementation
virtual ~CDaoIndexInfo();
BOOL m_bCleanupFieldInfo;
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
};
struct CDaoRelationFieldInfo
{
// Attributes
CString m_strName; // Primary
CString m_strForeignName; // Primary
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
};
struct CDaoRelationInfo
{
// Constructor
CDaoRelationInfo();
// Attributes
CString m_strName; // Primary
CString m_strTable; // Primary
CString m_strForeignTable; // Primary
long m_lAttributes; // Secondary
CDaoRelationFieldInfo* m_pFieldInfos; // Secondary
short m_nFields; // Secondary
// Implementation
virtual ~CDaoRelationInfo();
BOOL m_bCleanupFieldInfo;
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
};
struct CDaoQueryDefInfo
{
// Attributes
CString m_strName; // Primary
short m_nType; // Primary
COleDateTime m_dateCreated; // Secondary
COleDateTime m_dateLastUpdated; // Secondary
BOOL m_bUpdatable; // Secondary
BOOL m_bReturnsRecords; // Secondary
CString m_strSQL; // All
CString m_strConnect; // All
short m_nODBCTimeout; // See readme
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
};
struct CDaoParameterInfo
{
// Attributes
CString m_strName; // Primary
short m_nType; // Primary
COleVariant m_varValue; // Secondary
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
};
////////////////////////////////////////////////////////////////////////
// DAO Helpers
//
// Flags for getting and/or setting object properties
#define AFX_DAO_PRIMARY_INFO 0x00000001 // Get only primary
#define AFX_DAO_SECONDARY_INFO 0x00000002 // Get primary & secondary
#define AFX_DAO_ALL_INFO 0x00000004 // Get All info
// Jet engine TRUE/FALSE definitions
#define AFX_DAO_TRUE (-1L)
#define AFX_DAO_FALSE 0
// Set CDaoRecordset::Open option to use m_nDefaultType
#define AFX_DAO_USE_DEFAULT_TYPE (-1L)
// Flags used for Move/Find
#define AFX_DAO_NEXT (+1L)
#define AFX_DAO_PREV (-1L)
#define AFX_DAO_FIRST LONG_MIN
#define AFX_DAO_LAST LONG_MAX
// Default sizes for DFX function PreAlloc sizes
#define AFX_DAO_TEXT_DEFAULT_SIZE 255
#define AFX_DAO_BINARY_DEFAULT_SIZE 2048
#define AFX_DAO_LONGBINARY_DEFAULT_SIZE 32768
// Flag used for DFX functions dwBindOptions bitmask
#define AFX_DAO_ENABLE_FIELD_CACHE 0x01
#define AFX_DAO_DISABLE_FIELD_CACHE 0
#define AFX_DAO_CACHE_BY_VALUE 0x80 // MFC Internal
// Field Flags, used to indicate status of fields
#define AFX_DAO_FIELD_FLAG_DIRTY 0x01
#define AFX_DAO_FIELD_FLAG_NULL 0x02
#define AFX_DAO_FIELD_FLAG_NULLABLE_KNOWN 0x04
#define AFX_DAO_FIELD_FLAG_NULLABLE 0x08
// Extended error codes
#define NO_AFX_DAO_ERROR 0
#define AFX_DAO_ERROR_MIN 2000
#define AFX_DAO_ERROR_ENGINE_INITIALIZATION AFX_DAO_ERROR_MIN + 0
#define AFX_DAO_ERROR_DFX_BIND AFX_DAO_ERROR_MIN + 1
#define AFX_DAO_ERROR_OBJECT_NOT_OPEN AFX_DAO_ERROR_MIN + 2
#define AFX_DAO_ERROR_MAX AFX_DAO_ERROR_MIN + 2
// Object status flags
#define AFX_DAO_IMPLICIT_WS 0x01
#define AFX_DAO_IMPLICIT_DB 0x02
#define AFX_DAO_IMPLICIT_QD 0x04
#define AFX_DAO_IMPLICIT_TD 0x08
#define AFX_DAO_IMPLICIT_CLOSE 0x40
#define AFX_DAO_DEFAULT_WS 0x80
// CDaoRecordView status flags
#define AFX_DAOVIEW_SCROLL_NEXT 0x01
#define AFX_DAOVIEW_SCROLL_LAST 0x02
#define AFX_DAOVIEW_SCROLL_BACKWARD 0x04
// Logging helpers
void AFXAPI AfxDaoCheck(SCODE scode, LPCSTR lpszDaoCall,
LPCSTR lpszFile, int nLine, int nError = NO_AFX_DAO_ERROR,
BOOL bMemOnly = FALSE);
#ifdef _DEBUG
void AFXAPI AfxDaoTrace(SCODE scode, LPCSTR lpszDaoCall,
LPCSTR lpszFile, int nLine);
#endif
#ifdef _DEBUG
#define DAO_CHECK(f) AfxDaoCheck(f, #f, THIS_FILE, __LINE__)
#define DAO_CHECK_ERROR(f, err) AfxDaoCheck(f, #f, THIS_FILE, __LINE__, err)
#define DAO_CHECK_MEM(f) AfxDaoCheck(f, #f, THIS_FILE, __LINE__, \
NO_AFX_DAO_ERROR, TRUE)
#define DAO_TRACE(f) AfxDaoTrace(f, #f, THIS_FILE, __LINE__)
#else
#define DAO_CHECK(f) AfxDaoCheck(f, NULL, NULL, 0)
#define DAO_CHECK_ERROR(f, err) AfxDaoCheck(f, NULL, NULL, 0, err)
#define DAO_CHECK_MEM(f) AfxDaoCheck(f, NULL, NULL, 0, \
NO_AFX_DAO_ERROR, TRUE)
#define DAO_TRACE(f) f
#endif
/////////////////////////////////////////////////////////////////////////////
// CDaoFieldExchange - for field exchange
class CDaoFieldExchange
{
// Attributes
public:
enum DFX_Operation
{
AddToParameterList, // builds PARAMETERS clause
AddToSelectList, // builds SELECT clause
BindField, // sets up binding structure
BindParam, // sets parameter values
Fixup, // sets NULL status
AllocCache, // allocates cache used for dirty check
StoreField, // saves current record to cache
LoadField, // restores cached data to member vars
FreeCache, // frees cache
SetFieldNull, // sets field status & value to NULL
MarkForAddNew, // marks fields dirty if not PSEUDO NULL
MarkForEdit, // marks fields dirty if don't match cache
SetDirtyField, // sets field values marked as dirty
#ifdef _DEBUG
DumpField,
#endif
MaxDFXOperation, // dummy operation type for input checking
};
UINT m_nOperation; // type of exchange operation
CDaoRecordset* m_prs; // recordset handle
// Operations
public:
enum FieldType
{
none,
outputColumn,
param,
};
void SetFieldType(UINT nFieldType);
BOOL IsValidOperation();
// Implementation
public:
CDaoFieldExchange(UINT nOperation, CDaoRecordset* prs,
void* pvField = NULL);
void Default(LPCTSTR lpszName, void* pv, DWORD dwFieldType,
DWORD dwBindOptions = 0);
static void PASCAL AppendParamType(CString& strParamList, DWORD dwParamType);
static CDaoFieldCache* PASCAL GetCacheValue(CDaoRecordset* prs, void* pv);
static void PASCAL SetNullValue(void* pv, DWORD dwDataType);
static BOOL PASCAL IsNullValue(void* pv, DWORD dwDataType);
static void PASCAL AllocCacheValue(CDaoFieldCache*& pCache, DWORD dwDataType);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -