1

Topic: Qt + ODBC

Kind time of days, dear colleagues! In the desktop application on Qt (v 5.7) actively I apply operation with ODBC. There is a DB on MS a SQL Server from which I work through ODBC. When I compile all under MSVS-2013 all the driver are, launched also a connection to a DB transits perfectly. I so understand that the driver-plug-in QSQLODBC.DLL (on C:\Qt\Qt5.7.0\5.7\msvc2013\plugins\sqldrivers \) provides it correctly. When I compile under MINGW, the connection to a DB is not present, in a window "Application Output" (QtCreator): QSqlDatabase: QODBC driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7 Here that becomes in my code: class DAL {public:... protected: QSqlDatabase m_dbConnection;//For ODBC connection support QString m_sServerName; QString m_sDSN;//ODBC Data-source Name QString m_sLogin; QString m_sPassword;} bool DAL:: Connect () {m_dbConnection = QSqlDatabase:: addDatabase ("QODBC");//Using qodbc (Qt plugin for ODBC support) m_dbConnection.setHostName (m_sServerName); m_dbConnection.setDatabaseName (m_sDSN); m_dbConnection.setUserName (m_sLogin); m_dbConnection.setPassword (m_sPassword); bool bResult = m_dbConnection.open (); return bResult;} I so understood that is possible: a) to Collect the driver under MINGW; b) to Find ready or to apply QSQLITE. What variant is more correct? Thankful in advance for any reasons!

2

Re: Qt + ODBC

Hello, AlexGin, you wrote: AG>... AG> I so understood that is possible: AG> a) to Collect the driver under MINGW; Yes, is the most easier AG> b) to Find ready or to apply QSQLITE. Yes AG> what variant is more correct? Both correct.

3

Re: Qt + ODBC

Hello, SaZ, you wrote: AG>> b) to Find ready or to apply QSQLITE. SaZ> Yes application QSQLITE: m_dbConnection = QSqlDatabase:: addDatabase ("QSQLITE"); Gives normal (by sight) Connection, however, performance of requests does not transit: QSqlQuery query (m_dbConnection); if (! query.exec ("SELECT ID, NAME, DESCRIPTION FROM dbo. CATEGORIES")) {QString qsErr = query.lastError ().text (); return 0;//Error occur} while (query.next ()) {...} we quit on an error. In line qsErr: no such table: dbo. CATEGORIES Unable to execute statement - it seems that does not see the table. I.e. it is obvious - that QSQLITE here does not transit. Possibly, optimal variant - to collect the driver under MINGW.

4

Re: Qt + ODBC

Hello, AlexGin, you wrote: AG> Hello, SaZ, you wrote: AG>>> b) to Find ready or to apply QSQLITE. SaZ>> Yes AG> we quit on an error. AG> in line qsErr: AG> no such table: dbo. CATEGORIES Unable to execute statement AG> - it seems that does not see the table. AG> I.e. it is obvious - that QSQLITE here does not transit. AG> it is probable, an optimal variant - to collect the driver under MINGW. As that is strange, connect to MS SQL and  SQLite the driver. And by mistake: well so means there there is no this table.

5

Re: Qt + ODBC

Hello, Dead Down, you wrote: AG>> we Quit on an error. AG>> in line qsErr: AG>> no such table: dbo. CATEGORIES Unable to execute statement AG>> - it seems that does not see the table. AG>> I.e. it is obvious - that QSQLITE here does not transit. AG>> it is probable, an optimal variant - to collect the driver under MINGW. > as that is strange, connect to MS SQL and  SQLite the driver. > And by mistake: well so means there there is no this table. The table there such is - when all works compiled under MSVS-2013 - all perfectly finds! Qt 5.7 jointly with studio. Well also would calm down. But I curious - want to understand how to force all it to work as well under MINGW Well and that that SQLite the driver does not work with MS SQL - so it was almost clear, simple decided to check up. How to collect under MINGW driver ODBC - here looked a little: http://mike-mvk.livejournal.com/4196.html http://www.sql.ru/forum/867383/qt-i-ms-sql-server-qodbc https://ru.opensuse.org/QT_%D0%B8_%D0%9 … 1%8B%D1%85