forked from voipmonitor/sniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
odbc.h
38 lines (35 loc) · 1.1 KB
/
odbc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef ODBC_H
#define ODBC_H
#include <stdlib.h>
#include <sql.h>
#include <sqlext.h>
#include <sqltypes.h>
class Odbc {
public:
Odbc();
~Odbc();
bool connect(const char *serverName, const char *userName, const char *password,
ulong odbcVersion = SQL_OV_ODBC3, ulong loginTimeOut = 10);
void disconnect();
bool connected();
void bindCol(SQLUSMALLINT colNumber, SQLSMALLINT targetType, SQLPOINTER targetValuePtr,
SQLLEN targetBufferLength = 0, SQLLEN *lenOrInd = NULL);
bool query(const char *query);
bool fetchRow();
SQLLEN getNumRows();
void diagError(SQLSMALLINT handleType);
void setLastErrorString(const char *errorString);
void clearLastError();
SQLRETURN getLastError() { return(this->lastError); }
SQLINTEGER getLastErrorNative() { return(this->lastErrorNative); }
char *getLastErrorString() { return(this->lastErrorString); }
bool okRslt(SQLRETURN rslt) { return rslt==SQL_SUCCESS || rslt==SQL_SUCCESS_WITH_INFO; }
private:
SQLHANDLE hEnvironment;
SQLHANDLE hConnection;
SQLHANDLE hStatement;
SQLRETURN lastError;
SQLINTEGER lastErrorNative;
char *lastErrorString;
};
#endif