Hello guys!! help me !! I try to connect mysql with qt but the qt don't open a conection read more!!
-
I dont't get to establish a connection with qt with mysql, i try a lot of way but don't open see de code
@QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setDatabaseName("C:\ProgramData\MySQL\MySQL Server 5.5\data\usuarios\db.opt");
db.setHostName("localhost");
db.setPassword("");
db.open();
if(!db.open())
ui->sinal->setText("disconected");
else
ui->sinal->setText("conected");@when will to compile always show disconected what did i do wrong?
have someone to help meI put de librarys
@#include <QMainWindow>
#include <QtSql/QSqlDatabase>
#include <QtSql>
#include <QtSql/qsqldatabase.h>
#include <QtSql/QSql>
#include <QtDebug>
#include <QtSql/qsql.h>@but don't connect
qxoz: code tags @ added
-
First thing First.
Are you sure you have a QMYSQL driver? -
second, that database name doesn't look correct. the only db driver that needs file path is sqlite.
third, no user name.