MySQL with QT
-
Hi guys,
I'm after a little support in connecting QT up to a MySQL database. I am going to need my application to contact both a remote and local database.
I have done some searching online however it all seems a little old with many results being from back in the days of QT3 which are of course dead now.
I do not want to use any crazy C Connector ports from C as these seem to be proving more trouble than they are worth. I am assuming however that both MySQL and QT talk the same talk on some form of ODBC connection.
If somebody could please help me get started with this, nothing fancy just connections and standard SQL Queries, no stored procedures or anything fancy like that.
Thanks
Andrew -
Did you already read the documentation?
http://doc.qt.nokia.com/4.7/qt-sql.htmlIf so, can you be more specific with your question?
-
Oh nope...Just looking now it says the MySQL driver is supported by default and it seems silly ridiculous to get it on the system having to install lots of programs cluttering up my drives.
Does anybody have a "pre-built" MySQL5.0 or 5.1 driver already built?
Thanks
Andrew -
If you want to use the Qt database driver for MYSQL, I guess all you have to is something like this:
@
QSqlDatabase myDb = QSqlDatabase::addDatabase("QMYSQL","DEFAULT");
myDb.setDatabaseName( [add your file name with path here] );
if(!myDb.open())
{
... your code
}
@ -
This what I'm currently getting running that, from my Application Output;
@Starting D:\Qt\2010.05\qt\IgmaServer-build-desktop\debug\IgmaServer.exe...
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC
D:\Qt\2010.05\qt\IgmaServer-build-desktop\debug\IgmaServer.exe exited with code -1073741819@And when I run the ODBC driver I just get;
@Starting D:\Qt\2010.05\qt\IgmaServer-build-desktop\debug\IgmaServer.exe...
D:\Qt\2010.05\qt\IgmaServer-build-desktop\debug\IgmaServer.exe exited with code -1073741819@