Click here to Skip to main content
15,892,298 members
Articles / Database Development / SQL Server

Accessing the Borland Database Engine (BDE) from Visual C++

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
17 Nov 19996 min read 225.4K   3.5K   45  
//////////////////////////////////////////////////////////////////////////
//  BdeException.h -- Interface for Borland Database Engine exception handler


#ifndef __BDEEXCEPION_H__
#define __BDEEXCEPION_H__

//#include "Ms-idapi.h" // header file for BDE API calls

// Actually, we are supposed to include Ms-idapi.h, but all it has is
// the following three lines anyway.  This allows me to keep idapi.h in the project directory  
#define	__FLAT__
#define __WIN32__
#include "idapi.h"


// These are additional errors that may be generated in the 
// CBdeDatabase class
#define BDEEXERR_FIELDNOTINTEGER 1
#define BDEEXERR_FIELDNOTFLOAT 2
#define BDEEXERR_FIELDNOTDATE 3
#define BDEEXERR_FIELDNOTSTRING 4
#define BDEEXERR_NOSUCHFIELD 5
#define BDEEXERR_NOTINEDITMODE 6
#define BDEEXERR_ALREADYINEDITMODE 7
#define BDEEXERR_INVALIDCURSOR 8
#define BDEEXERR_ALREADYOPEN 9
#define BDEEXERR_NOTINITIALIZED 10
#define BDEEXERR_INVALIDDATETIMEFORMAT 11
#define BDEEXERR_UNSUPPORTEDFIELDTYPE 12
#define BDEEXERR_UNSUPPORTEDBLOBTYPE 13
#define BDEEXERR_FIELDNOTBOOLEAN 14
#define BDEEXERR_INVALIDFIELDINDEX 15
#define BDEEXERR_INVALIDFIELDNAME 16


class CBdeException : public CException
{
	DECLARE_DYNAMIC(CBdeException);

// construction/destruction
public:
	CBdeException();
	CBdeException(DBIResult dbiResult);
	CBdeException(DBIResult dbiResult, CString strTable,
		CString strDatabaseName, LPCTSTR szAddInfo);
	CBdeException(DBIResult dbiResult, UINT nExtendedError, CString strTable,
		CString strDatabaseName, LPCTSTR szAddInfo);
	
// Attributes
public:


protected:
	DBIResult m_dbiResult;
	UINT m_nExtendedError;
	CString m_strAddInfo;
	CString m_strTableName;
	CString m_strDatabaseName;

// Operations
public:
	virtual BOOL GetErrorMessage(LPTSTR lpszError, UINT nMaxError, 
		PUINT pnHelpContext = NULL);
	CString GetErrorMessage(BOOL bVerbose = TRUE);
	virtual int ReportError(UINT nType = MB_OK, UINT nMessageID = 0);
	static CString GetExtendedErrorMessage(int nError);


protected:

// inlines
public:
	inline LPCTSTR GetTableName() {
		return m_strTableName; }
	inline LPCTSTR GetAddInfo() {
		return m_strAddInfo; }
	inline LPCTSTR GetDatabaseName() {
		return m_strDatabaseName; }
	



}; // end of class definition



#endif __BDEEXCEPION_H__

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
President Starpoint Software Inc.
United States United States
Bob Pittenger is founder and President of Starpoint Software Inc. He holds a B.A. degree from Miami University, M.S. and Ph.D. degrees from Purdue University, and an MBA from Xavier University. He has been programming since 1993, starting with Windows application development in C++/MFC and moving to C# and .NET around 2005 and is a .NET Microsoft Certified Professional Developer.

Bob is the author of two books:
Billionaire: How the Ultra-Rich Built Their Fortunes Through Good and Evil and What You Can Learn from Them
and
Wealthonomics: The Most Important Economic and Financial Concepts that Can Make You Rich Fast.
Visit http://www.billionairebook.net for more information.

Comments and Discussions