Important: Please read the Qt Code of Conduct -

Connecting to a MySQL database using ODBC

  • Hi
    I am new to Qt and I have tried to connect MySQL database using QODBC but it does not work at all. Can you please help me step by step.

    I am using windows 8.1 64 bit
    I have installed MySQL connector 5
    and configured system DSN and my code is

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

        qDebug() << "Opened!";
    } else {
        qDebug() << "Error = " << db.lastError().text();


    Thank you

    [edit: please add @ tags around your code, Eddy]

  • Hi,

    Welcome to the devnet forums.

    Please start new threads instead of continuing in old posts.

    I'll split this one.

  • I see a typo : localhost (h was omitted)

Log in to reply