Results 1 to 5 of 5

Thread: MS Sql native driver??

  1. #1
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default MS Sql native driver??

    Hello friends,

    I try to connect to a ms sql 2005 database. So I first try to use the QODBC driver ( QtSQL).

    Here is my Code:
    Qt Code:
    1. #include <QtGui>
    2. #include <QtSql>
    3. #include <QDebug>
    4.  
    5. int main(int argc, char* argv[]) {
    6. QApplication app(argc, argv);
    7.  
    8. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    9. db.setHostName("localhost");
    10. db.setDatabaseName("ExapleDB");
    11. db.setUserName("Admin");
    12. db.setPassword("admin");
    13.  
    14. if (!db.open()) {
    15. QSqlError err = db.lastError ();
    16. QMessageBox::information(0, QObject::tr("Fehler"), err.text());
    17. return 1;
    18. }
    19. QTableView tableView;
    20. // --- Alle Daten abfragen ---
    21. model.setTable("Artikel");
    22. model.select();
    23. model.setEditStrategy(QSqlTableModel::OnFieldChange);
    24. tableView.setModel(&model);
    25. tableView.setWindowTitle("SQL-Demonstration");
    26. tableView.show();
    27. return app.exec();
    28. }
    To copy to clipboard, switch view to plain text mode 

    I search for the Driver QODBC but I d´ont find it. I have install Qt by the installer 4.3.1.
    Than I read the Docu and I read this
    Note: You should use native drivers in preference to the ODBC driver where they are available. ODBC support can be used as a fallback for compliant databases if no native drivers are available.
    First: Where can I found a native Driver for MS Sql 2005?
    Second: How can I install the QODBC driver, because in the standard installation I have only the qsqlite4.dll?
    Last edited by wysota; 9th October 2007 at 12:12. Reason: Changed tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: MS Sql native driver??

    There is no native driver for MS SQL, you have to use ODBC. First check if you have the driver installed in plugins/sqldrivers subdirectory of your Qt installation. Then check if you have ODBC installed in your system, as Qt driver relies on it.

  3. #3
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: MS Sql native driver??

    No, i have not the qodbc driver installed. I have install qt via the executable.
    How can I post install the Driver?

  4. #4
    Join Date
    May 2007
    Location
    Germany
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: MS Sql native driver??

    Hello friends,

    when I try to compile the odbc driver I get some errors. What the hell is that??

    [HTML]tmp\obj\release_shared\qsql_odbc.o(.text+0xb445):q sql_odbc.cpp: undefined
    tmp\obj\release_shared\qsql_odbc.o(.text+0xe18e):q sql_odbc.cpp: undefined reference to `_imp___Z5qFreePv'
    tmp\obj\release_shared\qsql_odbc.o(.text+0xe24d):q sql_odbc.cpp: undefined reference to `_imp___Z5qFreePv'
    tmp\obj\release_shared\qsql_odbc.o(.text+0xe26d):q sql_odbc.cpp: undefined reference to `_imp___ZN9QListData5eraseEPPv'
    tmp\obj\release_shared\qsql_odbc.o(.text+0xe2ba):q sql_odbc.cpp: undefined reference to `_imp___Z5qFreePv'
    tmp\obj\release_shared\qsql_odbc.o(.text+0xf412):q sql_odbc.cpp: undefined reference to `SQLBindParameter@40'
    tmp\obj\release_shared\qsql_odbc.o(.text+0xf430):q sql_odbc.cpp: undefined reference to `_imp___Z5qFreePv'
    tmp\obj\release_shared\qsql_odbc.o(.rdata$_ZTV11QO DBCResult[vtable for QODBCResult]+0x14):qsql_odbc.cpp: undefined reference to `QSqlResult::setAt(int)'
    tmp\obj\release_shared\qsql_odbc.o(.rdata$_ZTV11QO DBCResult[vtable for QODBCResult]+0x18):qsql_odbc.cpp: undefined reference to `QSqlResult::setActive(bool)'
    tmp\obj\release_shared\qsql_odbc.o(.rdata$_ZTV11QO DBCResult[vtable for QODBCResult]+0x1c):qsql_odbc.cpp: undefined reference to `QSqlResult::setLastError(QSqlError const&)'
    tmp\obj\release_shared\qsql_odbc.o(.rdata$_ZTV11QO DBCResult[vtable for QODBCResult]+0x20):qsql_odbc.cpp: undefined reference to `QSqlResult::setQuery(QString const&)'
    tmp\obj\release_shared\qsql_odbc.o(.rdata$_ZTV11QO DBCResult[vtable for QODBCResult]+0x24):qsql_odbc.cpp: undefined reference to `QSqlResult::setSelect(bool)'
    tmp\obj\release_shared\qsql_odbc.o(.rdata$_ZTV11QO DBCResult[vtable for QODBCResult]+0x28):qsql_odbc.cpp: undefined reference to `QSqlResult::setForwardOnly(bool)'
    tmp\obj\release_shared\qsql_odbc.o(.rdata$_ZTV11QO DBCResult[vtable for QODBCResult]+0x34):qsql_odbc.cpp: undefined reference to `QSqlResult::savePrepare(QString const&)'
    tmp\obj\release_shared\qsql_odbc.o(.rdata$_ZTV11QO DBCResult[vtable for QODBCResult]+0x38):qsql_odbc.cpp: undefined reference to `QSqlResult::bindValue(int, QVariant const&, QFlags<QSql::ParamTypeFlag>)'
    tmp\obj\release_shared\qsql_odbc.o(.rdata$_ZTV11QO DBCResult[vtable for QODBCResult]+0x3c):qsql_odbc.cpp: undefined reference to `QSqlResult::bindValue(QString const&, QVariant const&, QFlags<QSql::ParamTypeFlag>)'
    tmp\obj\release_shared\qsql_odbc.o(.rdata$_ZTV11QO DBCResult[vtable for QODBCResult]+0x6c):qsql_odbc.cpp: undefined reference to `QSqlResult::lastInsertId() const'
    tmp\obj\release_shared\qsql_odbc.o(.rdata$_ZTV11QO DBCResult[vtable for QODBCResult]+0x70):qsql_odbc.cpp: undefined reference to `QSqlResult::virtual_hook(int, void*)'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN7QVect orI8QVariantE4freeEP16QVectorTypedDataIS0_E[QVector<QVariant>::free(QVectorTypedData<QVariant> *)]+0x25):qsql_odbc.cpp: undefined reference to `_imp___ZN8QVariantD1Ev'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN7QVect orI8QVariantE4freeEP16QVectorTypedDataIS0_E[QVector<QVariant>::free(QVectorTypedData<QVariant> *)]+0x37):qsql_odbc.cpp: undefined reference to `_imp___Z5qFreePv'
    tmp\obj\release_shared\qsql_odbc.o(.text$_Z17qRegi sterMetaTypeIPvEiPKcPT_[int qRegisterMetaType<void*>(char const*, void**)]+0x20):qsql_odbc.cpp: undefined reference to `_imp___ZN9QMetaType12registerTypeEPKcPFvPvEPFS2_P KvE'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN7QVect orI8QVariantE7reallocEii[QVector<QVariant>::realloc(int, int)]+0x8f):qsql_odbc.cpp: undefined reference to `_imp___Z8qReallocPvj'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN7QVect orI8QVariantE7reallocEii[QVector<QVariant>::realloc(int, int)]+0x11f):qsql_odbc.cpp: undefined reference to `_imp___ZN8QVariantC1ERKS_'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN7QVect orI8QVariantE7reallocEii[QVector<QVariant>::realloc(int, int)]+0x1bb):qsql_odbc.cpp: undefined reference to `_imp___ZN8QVariantD1Ev'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN7QVect orI8QVariantE7reallocEii[QVector<QVariant>::realloc(int, int)]+0x27b):qsql_odbc.cpp: undefined reference to `_imp___ZN8QVariantD1Ev'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN7QVect orI8QVariantE7reallocEii[QVector<QVariant>::realloc(int, int)]+0x2e8):qsql_odbc.cpp: undefined reference to `_imp___ZN11QVectorData6mallocEiiiPS_'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN7QVect orI8QVariantE6resizeEi[QVector<QVariant>::resize(int)]+0x6c):qsql_odbc.cpp: undefined reference to `_imp___ZN11QVectorData4growEiiib'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN7QVect orI8QVariantE4fillERKS0_i[QVector<QVariant>::fill(QVariant const&, int)]+0x4d):qsql_odbc.cpp: undefined reference to `_imp___ZN8QVariantC1ERKS_'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN7QVect orI8QVariantE4fillERKS0_i[QVector<QVariant>::fill(QVariant const&, int)]+0xad):qsql_odbc.cpp: undefined reference to `_imp___ZN8QVariantaSERKS_'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN7QVect orI8QVariantE4fillERKS0_i[QVector<QVariant>::fill(QVariant const&, int)]+0xce):qsql_odbc.cpp: undefined reference to `_imp___ZN8QVariantD1Ev'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN7QVect orI8QVariantE4fillERKS0_i[QVector<QVariant>::fill(QVariant const&, int)]+0x107):qsql_odbc.cpp: undefined reference to `_imp___ZN8QVariantD1Ev'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN5QList I10QByteArrayE4freeEPN9QListData4DataE[QList<QByteArray>::free(QListData:ata*)]+0x3f):qsql_odbc.cpp: undefined reference to `_imp___Z5qFreePv'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN5QList I10QByteArrayE4freeEPN9QListData4DataE[QList<QByteArray>::free(QListData:ata*)]+0x63):qsql_odbc.cpp: undefined reference to `_imp___Z5qFreePv'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN5QList I10QByteArrayED1Ev[QList<QByteArray>::~QList()]+0x16):qsql_odbc.cpp: undefined reference to `_imp___ZN9QListData11shared_nullE'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN5QList I10QByteArrayE13detach_helperEv[QList<QByteArray>::detach_helper()]+0x4c):qsql_odbc.cpp: undefined reference to `_imp___ZN9QListData7detach2Ev'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN5QList I10QByteArrayE6appendERKS0_[QList<QByteArray>::append(QByteArray const&)]+0x6e):qsql_odbc.cpp: undefined reference to `_imp___ZN9QListData6appendEv'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN5QList I10QByteArrayE6appendERKS0_[QList<QByteArray>::append(QByteArray const&)]+0x110):qsql_odbc.cpp: undefined reference to `_imp___Z5qFreePv'
    tmp\obj\release_shared\qsql_odbc.o(.text$_ZN5QList I10QByteArrayE6appendERKS0_[QList<QByteArray>::append(QByteArray const&)]+0x11e):qsql_odbc.cpp: undefined reference to `_imp___Z5qFreePv'
    tmp\obj\release_shared\moc_qsql_odbc.o(.text+0x82) :moc_qsql_odbc.cpp: undefined reference to `QSqlDriver::qt_metacall(QMetaObject::Call, int, void**)'
    tmp\obj\release_shared\moc_qsql_odbc.o(.text+0x92) :moc_qsql_odbc.cpp: undefined reference to `_imp___ZN10QSqlDriver16staticMetaObjectE'
    tmp\obj\release_shared\moc_qsql_odbc.o(.text+0x5a) :moc_qsql_odbc.cpp: undefined reference to `QSqlDriver::qt_metacast(char const*)'
    tmp\obj\release_shared\moc_qsql_odbc.o(.rdata$_ZTV 11QODBCDriver[vtable for QODBCDriver]+0x1c):moc_qsql_odbc.cpp: undefined reference to `QObject::event(QEvent*)'
    tmp\obj\release_shared\moc_qsql_odbc.o(.rdata$_ZTV 11QODBCDriver[vtable for QODBCDriver]+0x20):moc_qsql_odbc.cpp: undefined reference to `QObject::eventFilter(QObject*, QEvent*)'
    tmp\obj\release_shared\moc_qsql_odbc.o(.rdata$_ZTV 11QODBCDriver[vtable for QODBCDriver]+0x24):moc_qsql_odbc.cpp: undefined reference to `QObject::timerEvent(QTimerEvent*)'
    tmp\obj\release_shared\moc_qsql_odbc.o(.rdata$_ZTV 11QODBCDriver[vtable for QODBCDriver]+0x28):moc_qsql_odbc.cpp: undefined reference to `QObject::childEvent(QChildEvent*)'
    tmp\obj\release_shared\moc_qsql_odbc.o(.rdata$_ZTV 11QODBCDriver[vtable for QODBCDriver]+0x2c):moc_qsql_odbc.cpp: undefined reference to `QObject::customEvent(QEvent*)'
    tmp\obj\release_shared\moc_qsql_odbc.o(.rdata$_ZTV 11QODBCDriver[vtable for QODBCDriver]+0x30):moc_qsql_odbc.cpp: undefined reference to `QObject::connectNotify(char const*)'
    tmp\obj\release_shared\moc_qsql_odbc.o(.rdata$_ZTV 11QODBCDriver[vtable for QODBCDriver]+0x34):moc_qsql_odbc.cpp: undefined reference to `QObject::disconnectNotify(char const*)'
    tmp\obj\release_shared\moc_qsql_odbc.o(.rdata$_ZTV 11QODBCDriver[vtable for QODBCDriver]+0x38):moc_qsql_odbc.cpp: undefined reference to `QSqlDriver::isOpen() const'
    tmp\obj\release_shared\moc_qsql_odbc.o(.rdata$_ZTV 11QODBCDriver[vtable for QODBCDriver]+0x5c):moc_qsql_odbc.cpp: undefined reference to `QSqlDriver::sqlStatement(QSqlDriver::StatementTyp e, QString const&, QSqlRecord const&, bool) const'
    tmp\obj\release_shared\moc_qsql_odbc.o(.rdata$_ZTV 11QODBCDriver[vtable for QODBCDriver]+0x74):moc_qsql_odbc.cpp: undefined reference to `QSqlDriver::setOpen(bool)'
    tmp\obj\release_shared\moc_qsql_odbc.o(.rdata$_ZTV 11QODBCDriver[vtable for QODBCDriver]+0x78):moc_qsql_odbc.cpp: undefined reference to `QSqlDriver::setOpenError(bool)'
    tmp\obj\release_shared\moc_qsql_odbc.o(.rdata$_ZTV 11QODBCDriver[vtable for QODBCDriver]+0x7c):moc_qsql_odbc.cpp: undefined reference to `QSqlDriver::setLastError(QSqlError const&)'
    collect2: ld returned 1 exit status
    mingw32-make[1]: *** [..\..\..\..\plugins\sqldrivers\qsqlodbc4.dll] Error 1
    mingw32-make[1]: Leaving directory `C:/Qt/4.3.1/src/plugins/sqldrivers/odbc'
    mingw32-make: *** [release] Error 2

    C:\Qt\4.3.1\src\plugins\sqldrivers\odbc>[/HTML]

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: MS Sql native driver??

    My guess is that you don't have ODBC installed on your system. Please do that before trying to compile Qt ODBC driver.

Similar Threads

  1. Building new SQL driver
    By Pragya in forum Installation and Deployment
    Replies: 1
    Last Post: 27th June 2007, 09:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.