Goal of class CGOdbcConnection
is work around HDBC connection handle.
Also, this class is responsible to create statement objects.
Methods
void connect(const char *szDSN, const char *szUID, const char *szPWD);
Method is responsible for establishing of connection with specified datasource.
szDSN | Name of ODBC datasource name | |
szUID | User name for login | |
szPWD | Password for login |
void connect(const char *szString, HWND hWnd = 0);
Method is responsible for establishing of connection with help of connection string (see description of ODBC's SQLDriverConnect function for details)
szString | Connection string | |
hWnd | Optional windows handle, which can be used to show login dialog |
CGOdbcStmt *createStatement();
Method creates statement.
void freeStatement(CGOdbcStmt *);
Method deletes statement.
CGOdbcStmt *executeSelect(const char *szSQL);
Method executes "select" query on current connection and return statement with
result cursor. Method can return null
if result doesn't contain columns. Method can throw CGOdbcEx exception.
int executeUpdate(const char *szSQL);
Method executes non-"select" query on current connection and return number of affecter rows.
Method can throw CGOdbcEx exception.
CGOdbcStmt *getListOfTypes();
Method selects list of datatypes and returns it as cursor. Method can throw CGOdbcEx exception.
CGOdbcStmt *getListOfTables(const char *szTableMask = 0);
Method selects list of table (all or by like mask) and returns it as cursor. Method can throw CGOdbcEx exception.
CGOdbcStmt *getListOfColumns(const char *szTableMask = 0);
Method selects list of columns (all or by table name or by like mask for table name) and returns it as cursor. Method can throw CGOdbcEx exception.
void setTransMode(bool bAutoCommit);
Method switched transaction mode for current connection to manual or auto-commit mode. Method can throw CGOdbcEx exception.
void commit();
Method commits transaction in manual mode. Method can throw CGOdbcEx exception.
void rollback();
Method rollbacks transaction in manual mode. Method can throw CGOdbcEx exception.
const char *getDriver();
Method returns file name (without path) of the driver, used in established connection.
void close();
Method closes connection.
HDBC getConnect();
Method returns ODBC connection handle.
void setConnect(HDBC);
Method set external ODBC connection handle. This connection will not be
freed during close
operation.
bool firstDSN(char *szBuff, int lBuffMaxLen);
bool nextDSN(char *szBuff, int lBuffMaxLen);
Pair of the functions, which is used to enumerate list of all available DSN. Function return true
if DSN is successfully obtained.