PDA

View Full Version : a guide on connecting to mysql database



hezbon
6th July 2012, 09:01
hi all i have gone through the internet to try find how to connect to the database but i think there is a library that i need to add to to my simple desktop application, while trying to create a database instance with this line
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");

this (QSqlDatabase) comes out as undeclared identifier and that from my newbie knowledge i think is because their is lack of an essential library, i have checked how to do it in command prompt but the commands are not recognized, can somebody help me with step guide on how to do this?

high_flyer
6th July 2012, 12:20
Make sure your db driver is built, if its not here is how your build it:
http://qt-project.org/doc/qt-4.8/sql-driver.html#supported-databases

And this is how you use it:
http://qt-project.org/doc/qt-4.8/qsqldatabase.html

wysota
6th July 2012, 12:22
... and make sure your project file includes the following entry:
QT += sql

hezbon
6th July 2012, 14:01
thank you all guys. I have work pretty, can query and insert now ope to move to next level by next week, am now trying to do serial port communication let me work on this and if am stack I will get to you guys in this forum helpful, let me do my research first.:)