home *** CD-ROM | disk | FTP | other *** search
- // ODBCErr.h -- An error object for an error or status message
- // generated by the SQL Server ODBC driver.
- //
- // This file is part of Microsoft SQL Server online documentation.
- // Copyright (C) 1992-1997 Microsoft Corporation. All rights reserved.
- //
- // This source code is an intended supplement to the Microsoft SQL
- // Server online references and related electronic documentation.
- #ifndef __ODBCERR_H__
- #define __ODBCERR_H__
-
- #ifndef __AFXWIN_H__
- #error include 'stdafx.h' before including this file for PCH
- #endif
-
- #include "SQL.h"
- #include "SQLExt.h"
-
- #include "odbcss.h"
-
- // Macros
- #define DYNFUNC_MAX 32
- #define SERVERNAME_MAX 16
- #define SSPROCNAME_MAX 64
-
- #define INVALID_OBJECT ((SQLRETURN) 0xBEEF)
-
- /////////////////////////////////////////////////////////////////////////////
- // CODBCErr -- An ODBC error or status message and details.
- class CODBCErr : public CObject
- {
- DECLARE_DYNAMIC(CODBCErr)
-
- // Construction
- public:
- CODBCErr(SQLSMALLINT eHandleType, SQLHANDLE hODBC, SQLINTEGER nRow);
-
- protected:
-
- // Implementation
- public:
- void Format(CString& strError);
- virtual ~CODBCErr();
-
-
- private:
- // Diagnostic record detail
- SQLINTEGER m_nRow;
- SQLINTEGER m_nCol;
- SQLINTEGER m_nNativeErr;
- TCHAR m_acOrigin[SQL_SQLSTATE_SIZE + 1];
- TCHAR m_acConnectName[SQL_MAX_DSN_LENGTH + 1];
- TCHAR m_acMessage[SQL_MAX_MESSAGE_LENGTH + 1];
- TCHAR m_acServer[SERVERNAME_MAX + 1];
- TCHAR m_acSQLState[SQL_SQLSTATE_SIZE + 1];
- TCHAR m_acSubclass[SQL_SQLSTATE_SIZE + 1];
-
- // SQL Server-specific record detail
- SQLSMALLINT m_iSProcLine;
- SQLINTEGER m_iRaiseErrorState;
- SQLINTEGER m_iSeverity;
- TCHAR m_acProcName[SSPROCNAME_MAX + 1];
- TCHAR m_acSServer[SERVERNAME_MAX + 1];
-
- public:
- #ifdef _DEBUG
- virtual void Dump(CDumpContext& dc) const;
- virtual void AssertValid() const;
- #endif
- };
-
- /////////////////////////////////////////////////////////////////////////////
- // CODBCErrList -- A list of ODBC error objects. Inherits from CObject so
- // that CObject list, array, etc. are available to the class.
- class CODBCErrList : public CObject
- {
- DECLARE_DYNAMIC(CODBCErrList)
-
- // Construction
- public:
- CODBCErrList();
- CODBCErrList(SQLSMALLINT eHandleType, SQLHANDLE hODBC);
-
- protected:
-
- // implementation
- public:
- UINT Load(SQLSMALLINT eHandleType, SQLHANDLE hODBC);
- UINT GetCount()
- { return ((UINT) m_nErrors); }
-
- // Return the formatted header in the string passed.
- void FormatHeader(CString& strHeader);
-
- // Return a formatted error record in the string passed,
- void FormatErr(CString& strError, UINT nErr);
-
- // Log all errors to received file.
- void Log(LPCTSTR szLogFile);
-
- // Get the return code. Allows the caller to know that the
- // error list was created correctly.
- SQLRETURN GetReturnCode()
- { return (m_sRet); }
-
- virtual ~CODBCErrList();
-
- private:
- // Member variables record ODBC handle type and handle, number of
- // errors, and a list of the errors and the header (valid whether
- // an error occurred or not).
- SQLHANDLE m_hODBC;
- SQLSMALLINT m_eHandleType;
- SQLINTEGER m_nErrors;
- CObList m_listErrors;
-
- // Diagnostic header detail
- TCHAR m_acDynFunc[DYNFUNC_MAX + 1];
- SQLINTEGER m_iDynFunc;
- SQLRETURN m_sRet;
-
- public:
- #ifdef _DEBUG
- virtual void Dump(CDumpContext& dc) const;
- virtual void AssertValid() const;
- #endif
- };
-
- #endif // __ODBCERR_H__
-