GDAL

- Main Page
- Related Pages
- Classes
- Files
- Download
- Issue Tracker

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
CPLODBCSession Class Reference

A class representing an ODBC database session. More...

`#include <cpl_odbc.h>`

## Public Member Functions
| CPLODBCSession ()
| Constructor.
| ~CPLODBCSession ()
| Destructor.
int | EstablishSession (const char *pszDSN, const char *pszUserid, const char *pszPassword)
| Connect to database and logon. More...
const char * | GetLastError ()
| Returns the last ODBC error message. More...
int | ClearTransaction ()
| Clear transaction.
int | BeginTransaction ()
| Begin transaction.
int | CommitTransaction ()
| Commit transaction.
int | RollbackTransaction ()
| Rollback transaction.
int | IsInTransaction ()
| Returns whether a transaction is active.
int | CloseSession ()
| Close session.
int | Failed (int, HSTMT=nullptr)
| Test if a return code indicates failure, return TRUE if that is the case. More...
HDBC | GetConnection ()
| Return connection handle.
HENV | GetEnvironment ()
| Return GetEnvironment handle.
bool | ConnectToMsAccess (const char *pszName, const char *pszDSNStringTemplate)
| Connects to a Microsoft Access database. More...

## Detailed Description

A class representing an ODBC database session.

Includes error collection services.

## Member Function Documentation

bool CPLODBCSession::ConnectToMsAccess | ( | const char * | pszName,
|  | const char * | pszDSNStringTemplate
| ) |  |

Connects to a Microsoft Access database.

Parameters

  pszName | The file name of the Access database to connect to. This is not optional.
  pszDSNStringTemplate | optional DSN string template for Microsoft Access ODBC Driver. If not specified, then a set of known driver templates will be used automatically as a fallback. If specified, it is the caller's responsibility to ensure that the template is correctly formatted.

Returns
  TRUE on success or FALSE on failure. Errors will automatically be reported via CPLError.

Since
  GDAL 3.2

int CPLODBCSession::EstablishSession | ( | const char * | pszDSN,
|  | const char * | pszUserid,
|  | const char * | pszPassword
| ) |  |

Connect to database and logon.

Parameters

  pszDSN | The name of the DSN being used to connect. This is not optional.
  pszUserid | the userid to logon as, may be NULL if not not required, or provided by the DSN.
  pszPassword | the password to logon with. May be NULL if not required or provided by the DSN.

Returns
  TRUE on success or FALSE on failure. Call GetLastError() to get details on failure.

int CPLODBCSession::Failed | ( | int | nRetCode,
|  | HSTMT | hStmt = `nullptr`
| ) |  |

Test if a return code indicates failure, return TRUE if that is the case.

Also update error text.

ODBC error messages are reported in the following format: [SQLState]ErrorMessage(NativeErrorCode)

Multiple error messages are delimeted by ",".

const char * CPLODBCSession::GetLastError | ( |  | ) |

Returns the last ODBC error message.

Returns
  pointer to an internal buffer with the error message in it. Do not free or alter. Will be an empty (but not NULL) string if there is no pending error info.

The documentation for this class was generated from the following files:

- cpl_odbc.h
- cpl_odbc.cpp