开发者

xampp Mysql connection using QT in Windows OS

开发者 https://www.devze.com 2023-02-28 17:23 出处:网络
i am having a problem in connecting xampp mysql and QT. Here is the code that i had found in the net but gives an error:

i am having a problem in connecting xampp mysql and QT. Here is the code that i had found in the net but gives an error:

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

        db.setHostName("localhost");
        db.setDatabaseName("sample_datebase");
        db.setUserName("root");
        db.setPassword("");

        if(!db.open()) {
            QSqlError err = db.lastError();
            QMessageBox::information(0, QObject::tr("Error Connection!"), err.text(开发者_如何学C));
            return 1;
        }

the error message is:

Driver not loaded


Qt store all database-specific code within the drivers, such as QMYSQL driver. Compiled drivers are atored as a plugins. Before using plugins you need to build them with installed database libraries.

Detailed descriotion of how to build plugins for different databases under differen OS is described here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号