Help MySql Database not open
-
wrote on 23 Feb 2015, 14:01 last edited by
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
-
wrote on 23 Feb 2015, 14:35 last edited by
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
-
wrote on 24 Feb 2015, 02:16 last edited by
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...
1/5