//-----------------------------------------------------------------------------
// Microsoft OLE DB TABLECOPY Sample
// Copyright (C) 1996 By Microsoft Corporation.
//
// @doc
//
// @module TABLE.H
//
//-----------------------------------------------------------------------------
#ifndef _TABLE_H_
#define _TABLE_H_
/////////////////////////////////////////////////////////////////
// Includes
//
/////////////////////////////////////////////////////////////////
#include "DataSource.h"
#include "TableCopy.h"
/////////////////////////////////////////////////////////////////
// Defines
//
/////////////////////////////////////////////////////////////////
enum ESQL_STMT
{
ESQL_SELECT,
ESQL_SELECT_BOGUS,
ESQL_INSERT,
ESQL_CREATE_TABLE,
ESQL_DROP_TABLE
};
/////////////////////////////////////////////////////////////////
// Structs for Column/Index info
//
/////////////////////////////////////////////////////////////////
struct TYPEINFO
{
WCHARwszTypeName[MAX_NAME_LEN];
USHORTwType;
ULONGulColumnSize;
WCHARwszCreateParams[MAX_NAME_LEN];
VARIANT_BOOLfIsNullable;
GUIDguidType;
};
struct INDEXINFO
{
WCHARwszIndexName[MAX_NAME_LEN];
WCHARwszColName[MAX_NAME_LEN];
DWORDdwCollation;
ULONGiOrdinal;
BOOLfUnique;
BOOLfIsPrimaryKey;
GUIDguidCol;
};
struct PRIMARYKEY
{
WCHARwszColName[MAX_NAME_LEN];
ULONGiOrdinal;
GUIDguidCol;
};
struct SCHEMATABLES
{
WCHARwszUserName[MAX_NAME_LEN];
WCHARwszTableName[MAX_NAME_LEN];
};
struct SCHEMACOLUMNS
{
WCHARwszColName[MAX_NAME_LEN];
ULONGiOrdinal;
GUIDguidCol;
DBCOLUMNFLAGSdwFlags;
USHORTwType;
ULONGulMaxLength;
USHORTwPrecision;
USHORTwScale;
GUIDguidType;
};
struct COLDESC
{
//DBCOLUMNINFO
WCHARwszColName[MAX_NAME_LEN];
ULONGiOrdinal;
DBCOLUMNFLAGSdwFlags;
ULONGulColumnSize;
DBTYPEwType;
BYTEbPrecision;
BYTEbScale;
//SCHEMACOLUMNS
GUIDguidCol;
//TYPEINFO
WCHARwszTypeName[MAX_NAME_LEN];
ULONGulCreateParams;
BOOLfIsNullable;
GUIDguidType;
};
/////////////////////////////////////////////////////////////////
// CTable
//
/////////////////////////////////////////////////////////////////
class CTable
{
public:
//Constructors
CTable(CWizard* pCWizard);
virtual ~CTable();
//Members
virtual BOOLConnect(HWND hWnd);
virtual BOOLIsConnected();
virtual BOOLTranslateNames();
virtual BOOLGetQuotedID(WCHAR* pwszOutBuff, WCHAR* pwszInBuff);
virtual HRESULT GetColInfo();
virtual HRESULT GetTypeInfo();
virtual HRESULT GetLiteralInfo();
virtual HRESULT CreateSQLStmt(ESQL_STMT eSqlStmt, WCHAR* pwszSqlStmt, BOOL fShowSql = TRUE);
virtual HRESULT MapTableInfo(CTable* pCSourceTable);
virtual HRESULT CreateTable();
virtual HRESULT GetRowset(REFIID riid, IUnknown** ppIRowset, HACCESSOR* phAccessor, ULONG* pcRowSize, ULONG ulBlobSize);
virtual HRESULT CopyData(CTable* pCSourceTable, ULONG* pcRows, ULONG ulParamSets, ULONG ulBlobSize);
virtual HRESULT CopyIndexes(CTable* pCSourceTable);
virtual HRESULT GetTypeInfoRowset(IAccessor** ppIAccessor, HACCESSOR* phAccessor, IRowset** ppIRowset);
//Data
WCHAR m_wszIDQuote[MAX_NAME_LEN];
WCHAR m_wszIDSeperator[MAX_NAME_LEN];
WCHARm_wszSchemaName[MAX_NAME_LEN];
WCHARm_wszTableName[MAX_NAME_LEN];
WCHARm_wszQualTableName[MAX_NAME_LEN];
//Index info
ULONGm_cIndexes;// Count of indexes
INDEXINFO*m_rgIndexInfo;// Index information
//ColumnInfo
ULONGm_cColumns;// Count of columns
COLDESC* m_rgColDesc;// Column Information
ULONG m_cBlobs;// Blob columns
//DataSource
CDataSource*m_pCDataSource;
CWizard*m_pCWizard;
};
#endif//_TABLE_H_