How to connect Qt with MYSQL??
How to connect Qt with MYSQL??
A camel can go 14 days without drink,
I can't!!!
Anybody there to help me... Am using the following code. It is not connected..
Qt Code:
db.setHostName("localhost"); db.setDatabaseName("Qt"); db.setUserName("root"); db.setPassword("1"); bool ok=false; ok=db.open();To copy to clipboard, switch view to plain text mode
Last edited by wysota; 18th March 2011 at 12:49.
this means that db.open() returns false?
The driver is available?
try with QSqlDatabase::isDriverAvailable
Qt Code:
To copy to clipboard, switch view to plain text mode
A camel can go 14 days without drink,
I can't!!!
Driver is not available... it returns false.. What should i do now??/
Do you have compiled mysql plugin? Do you have libmysql ?
What OS are you have?
Last edited by unit; 18th March 2011 at 13:01.
Try read Qt documentation before ask stupid question.
windows xp. I didnt try with the mysql plugins.
You need compile mysql plugin if you want use mysql
Do you read http://doc.trolltech.com/latest/sql-...rted-databases
Try read Qt documentation before ask stupid question.
Actually libmysql file is not there in the Qt installed location
This has been discussed many times in this forum and the link from 'unit' contains all the information you need, please read it.
Also, remember that you need to install the MySQL development files (library and include files).
After building the plugin, the libs will be located in:
\Qt\<Qt version>\qt\plugins\sqldrivers
at least that's the location for Qt sdk on XP with mingw.
I don't know if the OP got this issue resolved, but I'd like to add an extra piece of info for anybody else struggling with this. Make sure that you either add the path to MySQL's lib directory to your PATH or drop the libmysql.dll into the same directory as your executable. I spent hours of compiling, recompiling, installing, and uninstalling stuff thinking I had done something wrong, just to find out the DLL dependency was my issue. Hope this saves somebody else the trouble.
Bookmarks