home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 32 / IOPROG_32.ISO / SOFT / SqlEval7 / devtools / samples / ODBC / loaddata / odbcerr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-20  |  3.6 KB  |  130 lines

  1. // ODBCErr.h -- An error object for an error or status message
  2. //  generated by the SQL Server ODBC driver.
  3. //
  4. // This file is part of Microsoft SQL Server online documentation.
  5. // Copyright (C) 1992-1997 Microsoft Corporation. All rights reserved.
  6. //
  7. // This source code is an intended supplement to the Microsoft SQL
  8. // Server online references and related electronic documentation.
  9. #ifndef __ODBCERR_H__
  10. #define __ODBCERR_H__
  11.  
  12. #ifndef __AFXWIN_H__
  13.     #error include 'stdafx.h' before including this file for PCH
  14. #endif
  15.  
  16. #include "SQL.h"
  17. #include "SQLExt.h"
  18.  
  19. #include "odbcss.h"
  20.  
  21. // Macros
  22. #define         DYNFUNC_MAX        32
  23. #define         SERVERNAME_MAX     16
  24. #define         SSPROCNAME_MAX     64
  25.  
  26. #define         INVALID_OBJECT     ((SQLRETURN) 0xBEEF)
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CODBCErr -- An ODBC error or status message and details.
  30. class CODBCErr : public CObject
  31.     {
  32. DECLARE_DYNAMIC(CODBCErr)
  33.  
  34. // Construction
  35. public:
  36.     CODBCErr(SQLSMALLINT eHandleType, SQLHANDLE hODBC, SQLINTEGER nRow);
  37.  
  38. protected:
  39.  
  40. // Implementation
  41. public:
  42.     void Format(CString& strError);
  43.     virtual ~CODBCErr();
  44.  
  45.  
  46. private:
  47.     // Diagnostic record detail
  48.     SQLINTEGER  m_nRow;
  49.     SQLINTEGER  m_nCol;
  50.     SQLINTEGER  m_nNativeErr;
  51.     TCHAR       m_acOrigin[SQL_SQLSTATE_SIZE + 1];
  52.     TCHAR       m_acConnectName[SQL_MAX_DSN_LENGTH + 1];
  53.     TCHAR       m_acMessage[SQL_MAX_MESSAGE_LENGTH + 1];
  54.     TCHAR       m_acServer[SERVERNAME_MAX + 1];
  55.     TCHAR       m_acSQLState[SQL_SQLSTATE_SIZE + 1];
  56.     TCHAR       m_acSubclass[SQL_SQLSTATE_SIZE + 1];
  57.  
  58.     // SQL Server-specific record detail
  59.     SQLSMALLINT m_iSProcLine;
  60.     SQLINTEGER  m_iRaiseErrorState;
  61.     SQLINTEGER  m_iSeverity;
  62.     TCHAR       m_acProcName[SSPROCNAME_MAX + 1];
  63.     TCHAR       m_acSServer[SERVERNAME_MAX + 1];
  64.  
  65. public:
  66. #ifdef _DEBUG
  67.     virtual void Dump(CDumpContext& dc) const;
  68.     virtual void AssertValid() const;
  69. #endif
  70.     };
  71.  
  72. /////////////////////////////////////////////////////////////////////////////
  73. // CODBCErrList -- A list of ODBC error objects. Inherits from CObject so
  74. //  that CObject list, array, etc. are available to the class.
  75. class CODBCErrList : public CObject
  76.     {
  77. DECLARE_DYNAMIC(CODBCErrList)
  78.  
  79. // Construction
  80. public:
  81.     CODBCErrList();
  82.     CODBCErrList(SQLSMALLINT eHandleType, SQLHANDLE hODBC);
  83.  
  84. protected:
  85.  
  86. // implementation
  87. public:
  88.     UINT Load(SQLSMALLINT eHandleType, SQLHANDLE hODBC);
  89.     UINT GetCount()
  90.         { return ((UINT) m_nErrors); }
  91.  
  92.     // Return the formatted header in the string passed.
  93.     void FormatHeader(CString& strHeader);
  94.  
  95.     // Return a formatted error record in the string passed,
  96.     void FormatErr(CString& strError, UINT nErr);
  97.  
  98.     // Log all errors to received file.
  99.     void Log(LPCTSTR szLogFile);
  100.  
  101.     // Get the return code. Allows the caller to know that the
  102.     //  error list was created correctly.
  103.     SQLRETURN GetReturnCode()
  104.         { return (m_sRet); }
  105.  
  106.     virtual ~CODBCErrList();
  107.  
  108. private:
  109.     // Member variables record ODBC handle type and handle, number of
  110.     //  errors, and a list of the errors and the header (valid whether
  111.     //  an error occurred or not).
  112.     SQLHANDLE   m_hODBC;
  113.     SQLSMALLINT m_eHandleType;
  114.     SQLINTEGER  m_nErrors;
  115.     CObList     m_listErrors;
  116.  
  117.     // Diagnostic header detail
  118.     TCHAR       m_acDynFunc[DYNFUNC_MAX + 1];
  119.     SQLINTEGER  m_iDynFunc;
  120.     SQLRETURN   m_sRet;
  121.  
  122. public:
  123. #ifdef _DEBUG
  124.     virtual void Dump(CDumpContext& dc) const;
  125.     virtual void AssertValid() const;
  126. #endif
  127.     };
  128.  
  129. #endif // __ODBCERR_H__
  130.