PDA

View Full Version : QSqlDatabase: QODBC driver not loaded - problem



arturs
2nd June 2016, 10:20
Hi

I have the following code :


#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QSqlDatabase>
#include <QSqlQuery>



MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::on_pushButton_clicked()
{

QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=d:/TEST");
db.open();
}

after pressing button I see the messages "

QSqlDatabase: QODBC driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7"

How to solve the problem ?
How to load the driver.

I use Windows 7 64bit.

Regards
Artur

ChrisW67
2nd June 2016, 12:31
Either install the plugin or build it from source (http://doc.qt.io/qt-5/sql-driver.html#qodbc). Depends how you got your Qt libraries

arturs
3rd June 2016, 05:18
It is the description of installing plugin:

How to Build the ODBC Plugin on Windows

The ODBC header and include files should already be installed in the right directories. You just have to build the plugin as follows:

cd %QTDIR%\qtbase\src\plugins\sqldrivers\odbc
qmake odbc.pro
nmake
If you are not using a Microsoft compiler, replace nmake with make in the line above.

Note: This database plugin is not officially supported for Windows CE.

but I do not know where to find proper files :(

ChrisW67
3rd June 2016, 20:27
In the Qt library source code.

If you used the Qt Online Installer on Windows to get your Qt library then I would be very surprised if the QODBC plugin was not installed or easily installable.

arturs
4th June 2016, 13:26
Today I installed QT 5.6 once again (online instaler) and there is not QODBC plugin :(. I think there is a simple way to add the plugin but I do not know how to do it.

arturs
6th June 2016, 05:18
Nobody knows ?