Hey!
I need make an MySql connection, but I receive this error:
http://i.imgur.com/weMsU.png
My code:
#include <QtSql>
#include <QtSql>
To copy to clipboard, switch view to plain text mode
db->addDatabase( "QMYSQL3" ) ;
db->setDatabaseName( "dbToConnectTo" ) ;
db->setHostName( "localhost" ) ;
db->setUserName( "dbUser" ) ;
db->setPassword( "dbPassword" ) ;
if ( !db->open() ) {
Ola->setText("Failed opening database dbToConnectTo\nReason:\n\n" + db->lastError().driverText() + "\n\n" + db->lastError().databaseText());
Ola->setStyleSheet("background: none");
Ola->show();
}
QSqlDatabase *db = new QSqlDatabase();
db->addDatabase( "QMYSQL3" ) ;
db->setDatabaseName( "dbToConnectTo" ) ;
db->setHostName( "localhost" ) ;
db->setUserName( "dbUser" ) ;
db->setPassword( "dbPassword" ) ;
if ( !db->open() ) {
QMessageBox *Ola = new QMessageBox(ui->centralWidget);
Ola->setText("Failed opening database dbToConnectTo\nReason:\n\n" + db->lastError().driverText() + "\n\n" + db->lastError().databaseText());
Ola->setIcon(QMessageBox::Warning);
Ola->setStyleSheet("background: none");
Ola->show();
}
To copy to clipboard, switch view to plain text mode
In .pro:
QT += sql
QT += sql
To copy to clipboard, switch view to plain text mode
Please help me :/
hugs
Bookmarks