Help MySql Database not open
-
Hey, i need help to solve this.
!http://i.imgur.com/5Ve1AdV.png(http://i.imgur.com/5Ve1AdV.png)!
Error: QSqlQuery::prepare: database not open
Thanks to all who help.
-
Hi,
Check that the open call was successfull and if not at least print the error message you got
-
SGaist, /.
http://i.imgur.com/alXa8Sa.png
I can't understand what's happening;
#SOLVED
I changed:
@db = QSqlDatabase::addDatabase("QMYSQL","one");@
to:@db = QSqlDatabase::addDatabase("QMYSQL");@
SGaist, ty for reply :)
-
You're welcome !
If you name your connection then when creating e.g. QSqlQuery objects you also need to tell it which database connection you want to use
-
if you give a name to your database connection, so like Sgaist tell you, you need at open time to tell him to open this one (in your code, name was "one".
Then, if you naot give a name to the connection, this opening is for general use. It is a way to play with many different database connections...