Click here to Skip to main content
15,885,366 members
Articles / Desktop Programming / MFC

DTX - Database Toolbox For MFC Ver 1.8 (Freeware Version)

Rate me:
Please Sign up or sign in to vote.
3.88/5 (8 votes)
2 Apr 20024 min read 106.4K   3.6K   56  
DTX is a set of classes for editing and automatic read, write and display of datatabase fields, as well as 70+ ready to use classes
#if !defined(AFX_DTXADOTABLE_H__92C5D3CC_0A12_4896_B6F5_DC1212E6F495__INCLUDED_)
#define AFX_DTXADOTABLE_H__92C5D3CC_0A12_4896_B6F5_DC1212E6F495__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// dtxdaotable.h : header file
//

#undef EOF
#import <msado15.dll> rename_namespace("ado15")
using namespace ado15;

#if !defined(AFX_DTXTABLE_H_INCLUDED_)
#include "DTXTable.h"
#endif

#ifndef _ICRSINT_H_
#include <icrsint.h>
#endif

#ifndef __AFXDISP_H__
#include <afxdisp.h>
#endif

#ifndef __AFXPRIV_H__
#include <afxpriv.h>
#endif

struct CADOFieldInfo
{
	char m_strName[30]; 
	short m_nType;
	long m_lSize; 
	long m_lDefinedSize;
	long m_lAttributes;
	short m_nOrdinalPosition;
	BOOL m_bRequired;   
	BOOL m_bAllowZeroLength; 
	long m_lCollatingOrder;  
};

class CInitCom 
{
public:
	static BOOL m_InitCom;

	CInitCom()
	{
		m_InitCom = false;
		if(!m_InitCom)
		{
			::CoInitialize(NULL); 
			m_InitCom = true;
		}
	}

	~CInitCom()
	{
		if(m_InitCom)
		{
			 ::CoUninitialize(); 
			m_InitCom = false;
		}
	}

};
 

class CDTXADOTable: public CDTXTable
{
	CInitCom m_DTXInitOle;
	CString m_ADOSQL;
	CString m_ConnectionStr;
protected:
	_ConnectionPtr m_pConnection;
	_RecordsetPtr m_pRecordset;

	virtual BOOL intOpen();
	virtual BOOL intClose();

	virtual void ReadFieldArray();
	virtual void intUpdateRecord();
	virtual void intInsertRecord();
	virtual void intDeleteRecord();
	virtual void intGetCurrentRecord();

	virtual void intGoFirst();
	virtual void intGoLast();
	virtual void intGoNext();
	virtual void intGoPrev();
	virtual void intGo(UINT nRec);

	virtual UINT intGetRecordCount();
	virtual UINT intGetRecordPos();

	virtual BOOL intIsEOF();
	virtual BOOL intIsBOF();
	virtual BOOL TableOpened();
public:
	BOOL m_AutoDisconnect;
	CString m_UserName;
	CString m_Password;

	ado15::CursorTypeEnum	m_CursorType;
	ado15::LockTypeEnum		m_LockType;
	long m_OpenOptions;

	CDTXADOTable(CWnd* nOwner, CString nDatabaseName, CString nTableName = _T(""));
	~CDTXADOTable();

	_ConnectionPtr GetConnectionPtr()
	{ return m_pConnection; }

	void SetConnectionPtr(_ConnectionPtr nConnectionPtr)
	{ m_pConnection = nConnectionPtr; }

	_RecordsetPtr GetRecordsetPtr()
	{ return m_pRecordset; }

	CString GetConnectionStr()
	{ return m_ConnectionStr; }

	void SetConnectionStr(CString nStr)
	{ m_ConnectionStr = nStr; }

	CString GetSQLStr()
	{ return m_ADOSQL; }

	void SetSQLStr(CString nStr)
	{ m_ADOSQL = nStr; }

	virtual void SetFieldValue(LPCTSTR lpszName, COleVariant& varValue);
	virtual void SetFieldValue(int nIndex, COleVariant& varValue);
	virtual void GetFieldValue(LPCTSTR lpszName, COleVariant& varValue);
	virtual void GetFieldValue(int nIndex, COleVariant& varValue);
	
	bool GetFieldInfo(LPCTSTR lpFieldName, CADOFieldInfo* fldInfo);
	bool GetFieldInfo(int nIndex, CADOFieldInfo* fldInfo);
private:
	void CreateConnection();
};

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Turkey Turkey
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions