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

The Ultimate Grid Home Page

,
Rate me:
Please Sign up or sign in to vote.
5.00/5 (122 votes)
14 Sep 2013CPOL10 min read 4.6M   81.9K   418  
The Ultimate Grid is now Open Source
// ugrecset.h : header file
//
// This software along with its related components, documentation and files ("The Libraries")
// is � 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
// governed by a software license agreement ("Agreement").  Copies of the Agreement are
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
// to obtain this file, or directly from our office.  For a copy of the license governing
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.

/////////////////////////////////////////////////////////////////////////////
// CUGRecordset recordset


#define UG_ODBC_REPORTERROR
// Comment out this define to eliminate message boxes in the
// ODBC exception handlers - usefull for debugging...

#define UG_ODBC_MAXBINARY 65535
// type SQL_LONGVARBINARY is read into a CByteArray.
// if datasource reports Data Truncated, this value may need to
// be increased...

#define UG_ODBC_MAXTEXT 14000
// Basically truncation value for LONGVARCHAR (ms access memos).
// Also used to set buffer size for string.Format in GetCell
// When adjusting, 255 is a suggested minimum.

// structure to hold information gathered from SQLTables...
typedef struct tagSQLDatasourceInfo {
	SQLTCHAR	tableQualifier[128];
	SQLTCHAR	tableOwner[128];
	SQLTCHAR	tableName[128];
	SQLTCHAR	tableType[128];
	SQLTCHAR	remarks[255];
}SQLDatasourceInfo;


// minimal structure for getting field info...
typedef struct tagSQLColumnInfo {
	CString	strName;			// name of field
	CString strLabel;			// column label
	SWORD	nSQLType;			// SQL_XXX type of field
	UDWORD	nPrecision;			// precision of the data type
	SWORD	nScale;				// scale of the datatype
	SWORD	nNullable;			// does field allow nulls?
	SQLINTEGER	nUpdatable;			// is field updatable?
	SQLINTEGER	nAutoValue;			// is field a counter?
	void*	pValue;				// storage for retieved data
} SQLColumnInfo;




class CUGRecordset : public CRecordset
{

public:

	CString		m_defaultConnect;

	CPtrArray*	m_pSQLColumnInfoList;
		
	CString		m_strNameParam;
	CString		m_strOtherParam;
	CString		m_dataFileName;

	CUGRecordset(CDatabase* data);
	~CUGRecordset();

// added to CUGRecordset
	void CleanUp();
	BOOL BindFields(HSTMT hstmt);
	void ReportSQLError(RETCODE retcode, LPCTSTR func, HSTMT hstmt=SQL_NULL_HSTMT); 
	SQLColumnInfo* GetFieldInfo(int col);

// Overrides
	public:
	virtual CString GetDefaultSQL();
	virtual void DoFieldExchange(CFieldExchange* pFX);  // RFX support
	virtual BOOL Open(UINT nOpenType, LPCTSTR lpszSQL, DWORD dwOptions);  // RFX support
	virtual CString GetDefaultConnect();    // Default connection string

// Implementation
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Canada Canada
In January 2005, David Cunningham and Chris Maunder created TheUltimateToolbox.com, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.

Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.
This is a Organisation

476 members

Written By
Software Developer (Senior)
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions