Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
10 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: codbc.hxx
  8. //
  9. // Contents: Microsoft Internet Security Common
  10. //
  11. // History: 08-Sep-1997 pberkman created
  12. //
  13. //--------------------------------------------------------------------------
  14. #ifndef CODBC_HXX
  15. #define CODBC_HXX
  16. #include <sql.h>
  17. #include <sqlext.h>
  18. #undef SQL_SUCCEEDED
  19. //#define SQL_SUCCEEDED(err) ((err == SQL_SUCCESS) || (err == SQL_SUCCESS_WITH_INFO))
  20. typedef SQLRETURN (SQL_API *td_SQLSetStmtOption)(
  21. SQLHSTMT hstmt,
  22. SQLUSMALLINT fOption,
  23. SQLUINTEGER vParam);
  24. typedef SQLRETURN (SQL_API *td_SQLExecDirect)(
  25. SQLHSTMT hstmt,
  26. SQLCHAR FAR *szSqlStr,
  27. SQLINTEGER cbSqlStr);
  28. typedef SQLRETURN (SQL_API *td_SQLFetch)(
  29. SQLHSTMT hstmt);
  30. typedef SQLRETURN (SQL_API *td_SQLFreeConnect)(
  31. SQLHDBC hdbc);
  32. typedef SQLRETURN (SQL_API *td_SQLFreeEnv)(
  33. SQLHENV henv);
  34. typedef SQLRETURN (SQL_API *td_SQLFreeStmt)(
  35. SQLHSTMT hstmt,
  36. SQLUSMALLINT fOption);
  37. typedef SQLRETURN (SQL_API *td_SQLTransact)(
  38. SQLHENV henv,
  39. SQLHDBC hdbc,
  40. SQLUSMALLINT fType);
  41. typedef SQLRETURN (SQL_API *td_SQLError)(
  42. SQLHENV henv,
  43. SQLHDBC hdbc,
  44. SQLHSTMT hstmt,
  45. SQLCHAR FAR *szSqlState,
  46. SQLINTEGER FAR *pfNativeError,
  47. SQLCHAR FAR *szErrorMsg,
  48. SQLSMALLINT cbErrorMsgMax,
  49. SQLSMALLINT FAR *pcbErrorMsg);
  50. typedef SQLRETURN (SQL_API *td_SQLGetData)(
  51. SQLHSTMT hstmt,
  52. SQLUSMALLINT icol,
  53. SQLSMALLINT fCType,
  54. SQLPOINTER rgbValue,
  55. SQLINTEGER cbValueMax,
  56. SQLINTEGER FAR *pcbValue);
  57. typedef SQLRETURN (SQL_API *td_SQLAllocConnect)(
  58. SQLHENV henv,
  59. SQLHDBC FAR *phdbc);
  60. typedef SQLRETURN (SQL_API *td_SQLAllocEnv)(
  61. SQLHENV FAR *phenv);
  62. typedef SQLRETURN (SQL_API *td_SQLAllocStmt)(
  63. SQLHDBC hdbc,
  64. SQLHSTMT FAR *phstmt);
  65. typedef SQLRETURN (SQL_API *td_SQLDriverConnect)(
  66. SQLHDBC hdbc,
  67. SQLHWND hwnd,
  68. SQLCHAR FAR *szConnStrIn,
  69. SQLSMALLINT cbConnStrIn,
  70. SQLCHAR FAR *szConnStrOut,
  71. SQLSMALLINT cbConnStrOutMax,
  72. SQLSMALLINT FAR *pcbConnStrOut,
  73. SQLUSMALLINT fDriverCompletion);
  74. typedef SQLRETURN (SQL_API *td_SQLDisconnect)(
  75. SQLHDBC hdbc);
  76. class cODBC_
  77. {
  78. public:
  79. cODBC_(void);
  80. virtual ~cODBC_(void);
  81. BOOL Initialize(void);
  82. SQLRETURN SQLExecDirect(SQLHSTMT hstmt, SQLCHAR FAR *szSqlStr, SQLINTEGER cbSqlStr)
  83. { return((*fp_SQLExecDirect)(hstmt, szSqlStr, cbSqlStr)); }
  84. SQLRETURN SQLSetStmtOption(SQLHSTMT hstmt, SQLUSMALLINT fOption, SQLUINTEGER vParam)
  85. { return((*fp_SQLSetStmtOption)(hstmt, fOption, vParam)); }
  86. SQLRETURN SQLFetch(SQLHSTMT hstmt)
  87. { return((*fp_SQLFetch)(hstmt)); }
  88. SQLRETURN SQLFreeConnect(SQLHDBC hdbc)
  89. { return((*fp_SQLFreeConnect)(hdbc)); }
  90. SQLRETURN SQLFreeEnv(SQLHENV henv)
  91. { return((*fp_SQLFreeEnv)(henv)); }
  92. SQLRETURN SQLFreeStmt(SQLHSTMT hstmt, SQLUSMALLINT fOption)
  93. { return((*fp_SQLFreeStmt)(hstmt, fOption)); }
  94. SQLRETURN SQLTransact(SQLHENV henv, SQLHDBC hdbc, SQLUSMALLINT fType)
  95. { return((*fp_SQLTransact)(henv, hdbc, fType)); }
  96. SQLRETURN SQLError(SQLHENV henv, SQLHDBC hdbc, SQLHSTMT hstmt, SQLCHAR FAR *szSqlState,
  97. SQLINTEGER FAR *pfNativeError, SQLCHAR FAR *szErrorMsg,
  98. SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR *pcbErrorMsg)
  99. { return((*fp_SQLError)(henv, hdbc, hstmt, szSqlState,
  100. pfNativeError, szErrorMsg,
  101. cbErrorMsgMax, pcbErrorMsg)); }
  102. SQLRETURN SQLGetData(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType,
  103. SQLPOINTER rgbValue, SQLINTEGER cbValueMax, SQLINTEGER FAR *pcbValue)
  104. { return((*fp_SQLGetData)(hstmt, icol, fCType,
  105. rgbValue, cbValueMax, pcbValue)); }
  106. SQLRETURN SQLAllocConnect(SQLHENV henv, SQLHDBC FAR *phdbc)
  107. { return((*fp_SQLAllocConnect)(henv, phdbc)); }
  108. SQLRETURN SQLAllocEnv(SQLHENV FAR *phenv)
  109. { return((*fp_SQLAllocEnv)(phenv)); }
  110. SQLRETURN SQLAllocStmt(SQLHDBC hdbc, SQLHSTMT FAR *phstmt)
  111. { return((*fp_SQLAllocStmt)(hdbc, phstmt)); }
  112. SQLRETURN SQLDriverConnect(SQLHDBC hdbc, SQLHWND hwnd, SQLCHAR FAR *szConnStrIn,
  113. SQLSMALLINT cbConnStrIn, SQLCHAR FAR *szConnStrOut,
  114. SQLSMALLINT cbConnStrOutMax, SQLSMALLINT FAR *pcbConnStrOut,
  115. SQLUSMALLINT fDriverCompletion)
  116. { return((*fp_SQLDriverConnect)(hdbc, hwnd, szConnStrIn,
  117. cbConnStrIn, szConnStrOut,
  118. cbConnStrOutMax, pcbConnStrOut,
  119. fDriverCompletion)); }
  120. SQLRETURN SQLDisconnect(SQLHDBC hdbc)
  121. { return((*fp_SQLDisconnect)(hdbc)); }
  122. private:
  123. HINSTANCE hODBC32;
  124. td_SQLSetStmtOption fp_SQLSetStmtOption;
  125. td_SQLExecDirect fp_SQLExecDirect;
  126. td_SQLFetch fp_SQLFetch;
  127. td_SQLFreeConnect fp_SQLFreeConnect;
  128. td_SQLFreeEnv fp_SQLFreeEnv;
  129. td_SQLFreeStmt fp_SQLFreeStmt;
  130. td_SQLTransact fp_SQLTransact;
  131. td_SQLError fp_SQLError;
  132. td_SQLGetData fp_SQLGetData;
  133. td_SQLAllocConnect fp_SQLAllocConnect;
  134. td_SQLAllocEnv fp_SQLAllocEnv;
  135. td_SQLAllocStmt fp_SQLAllocStmt;
  136. td_SQLDriverConnect fp_SQLDriverConnect;
  137. td_SQLDisconnect fp_SQLDisconnect;
  138. };
  139. #endif // CODBC_HXX