Hi,
How do I get driver to connect my QT application with a database (preferably MySql) ?
I really can not find. : /
Tks.
Printable View
Hi,
How do I get driver to connect my QT application with a database (preferably MySql) ?
I really can not find. : /
Tks.
Here are SQL drivers:
C:\Qt\2010.05\qt\plugins\sqldrivers\
You should copy dll files from this folder in to C:\...\project_name-build-desktop\sqldrivers
You will probably also need some dll files from the folder:
C:\Qt\2010.05\qt\bin\
Don't forget to write Qt += core sql into .pro file
Here is an example:
Code:
static bool createConnection() { db.setHostName("HostName"); db.setDatabaseName("Database_ODBC_Name"); db.setUserName("user"); db.setPassword("password"); bool status; status = db.open(); return status; } int main(int argc, char *argv[]) { if (!createConnection()) { return 1; } else } return a.exec(); }
tbscope and Aleksandar thanks (obrigado).