QSqlQuery::prepare: database not open
-
@RekTek249 said in QSqlQuery::prepare: database not open:
"doesn't respond"
is the host reachable? Did you try to connect to the server using MySQL client?
-
Hi,
Are you running phpmyadmin on the same machine as the MySQL server ?
Are you running your application on the same machine as the server ?
If no to the second question, then did you correctly configure your MySQL server to accept external connections ? And also don't forget to secure them.
-
Then check that you are correctly using the same user name, password as you are using in PHPMyAdmin.
-
What exact error message do you get from your QSqlDatabase object ?
-
QSqlQuery query(db); query.prepare("INSERT INTO person (Username, Password, summ, Email) " "VALUES (:user, :pass, :summ, :mail)"); query.bindValue(":user", Username); // I do have variables set earlier query.bindValue(":pass", Password); query.bindValue(":summ", summ); query.bindValue(":mail", Email); query.exec();
The mistake is not giving you anything error?
please #include "QSqlError" and
if (db.open()) { QMessageBox msgBox; msgBox.setText("DB OPENED"); msgBox.exec(); } else{ qDebug() << db.lastError() }
By doing so we can understand what the problem is about anyway...
-
Did you check that the user you are using to connect to the database can be used for remote connections ?
-
@RekTek249 said in QSqlQuery::prepare: database not open:
It can.... What is the "2003" and 10060 meaning ? is 2003 the port ?
2003 is not a port name, so let's say the title of the problem.
-
@RekTek249 If that's what i do, it gives that error:
QSqlError("1045", "QMYSQL: Unable to connect", "Access denied for user 'rektek_write'@'*ip here*.' (using password: YES)")
If it's a permission problem, what do I need to do ? I have the insert one because that's the only thing I need to do...
-
Is this user authorised to access the database from outside that machine ?