Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QSQL_ODBC_H
00043 #define QSQL_ODBC_H
00044
00045 #include <QtSql/qsqldriver.h>
00046 #include <QtSql/qsqlresult.h>
00047
00048 #if defined (Q_OS_WIN32)
00049 #include <QtCore/qt_windows.h>
00050 #endif
00051
00052 #ifdef QT_PLUGIN
00053 #define Q_EXPORT_SQLDRIVER_ODBC
00054 #else
00055 #define Q_EXPORT_SQLDRIVER_ODBC Q_SQL_EXPORT
00056 #endif
00057
00058 #ifdef Q_OS_UNIX
00059 #define HAVE_LONG_LONG 1 // force UnixODBC NOT to fall back to a struct for BIGINTs
00060 #endif
00061
00062 #if defined(Q_CC_BOR)
00063
00064 # define _MSC_VER 900
00065 #endif
00066 #include <sql.h>
00067 #if defined(Q_CC_BOR)
00068 # undef _MSC_VER
00069 #endif
00070
00071 #include <sqlext.h>
00072
00073 QT_BEGIN_HEADER
00074
00075 QT_BEGIN_NAMESPACE
00076
00077 class QODBCPrivate;
00078 class QODBCDriverPrivate;
00079 class QODBCDriver;
00080 class QSqlRecordInfo;
00081
00082 class QODBCResult : public QSqlResult
00083 {
00084 public:
00085 QODBCResult(const QODBCDriver * db, QODBCDriverPrivate* p);
00086 virtual ~QODBCResult();
00087
00088 bool prepare(const QString& query);
00089 bool exec();
00090
00091 QVariant handle() const;
00092 virtual void setForwardOnly(bool forward);
00093
00094 protected:
00095 bool fetchNext();
00096 bool fetchFirst();
00097 bool fetchLast();
00098 bool fetchPrevious();
00099 bool fetch(int i);
00100 bool reset (const QString& query);
00101 QVariant data(int field);
00102 bool isNull(int field);
00103 int size();
00104 int numRowsAffected();
00105 QSqlRecord record() const;
00106 void virtual_hook(int id, void *data);
00107 bool nextResult();
00108
00109 private:
00110 QODBCPrivate *d;
00111 };
00112
00113 class Q_EXPORT_SQLDRIVER_ODBC QODBCDriver : public QSqlDriver
00114 {
00115 Q_OBJECT
00116 public:
00117 explicit QODBCDriver(QObject *parent=0);
00118 QODBCDriver(SQLHANDLE env, SQLHANDLE con, QObject * parent=0);
00119 virtual ~QODBCDriver();
00120 bool hasFeature(DriverFeature f) const;
00121 void close();
00122 QSqlResult *createResult() const;
00123 QStringList tables(QSql::TableType) const;
00124 QSqlRecord record(const QString& tablename) const;
00125 QSqlIndex primaryIndex(const QString& tablename) const;
00126 QVariant handle() const;
00127 QString formatValue(const QSqlField &field,
00128 bool trimStrings) const;
00129 bool open(const QString& db,
00130 const QString& user,
00131 const QString& password,
00132 const QString& host,
00133 int port,
00134 const QString& connOpts);
00135
00136 QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
00137
00138 protected Q_SLOTS:
00139 bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const;
00140
00141 protected:
00142 bool beginTransaction();
00143 bool commitTransaction();
00144 bool rollbackTransaction();
00145
00146 private:
00147 void init();
00148 bool endTrans();
00149 void cleanup();
00150 QODBCDriverPrivate* d;
00151 friend class QODBCPrivate;
00152 };
00153
00154 QT_END_NAMESPACE
00155
00156 QT_END_HEADER
00157
00158 #endif // QSQL_ODBC_H