Opening the database

  • Hi everyone,

    I have been having trouble open my database. Here is my code:
    In the .pro file
    @QT += sql@

    In the .cpp file:

    @#include <QtSql/QSqlDatabase>

    QSqlDatabase ods = QSqlDatabase::addDatabase("QODBC");

    ods.setDatabaseName("DRIVER={LibreOffice Driver (*.ods)};DBQ=" + QString("C:\Qt\2010.04\qt\Example2\yarzsample.ods") );
    if (
        qDebug() << "Opened successfully!";
        qDebug() << "Error";
        QMessageBox::critical(0, QObject::tr("Database Error"), "Failed to open");

    Everytime I run the program, the Error message box appear with "Failed to open file". So obviously, is not working. I wonder why?
    The truth is, all I am trying to do is be able to load names a dates from a .ods file (LibreOffice Calc). Can anyone offer advice?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.