How to connect to MySQL using QODBC
-
hello every one. I am new in Qt. I am trying to connect to Mysql using QODBC. her is the code.
QSqlDatabase db = QSqldatabase::addDatabase("QODBC");
db.setDatabaseName("Driver={MySQL ODBC 5.1 Driver}; DATABASE=localhost;");
db.setUserName("root");
db.setPAssword("gordo");
if(!db.open())
{
......
}
the error which i am getting is undefined reference to '_imp__ZN12QSqlDatabase17defaultConnectionE'.
where can the problem be? -
Thanks very much for your contribution. I have added the module and it runs smoothly.
-
How do i use the native driver instead? Should I add it to the make file of the project like like I did to sql module?
-
You should begin by reading "this":http://doc.qt.nokia.com/4.7/sql-driver.html#qmysql
-
My apologies to get this post alive again...
Just curious about this line:db.setDatabaseName("Driver={MySQL ODBC 5.1 Driver}; DATABASE=localhost;");
What is the string to make connection with MariaDB?
Thanks -
@U7Development Raise a brand new topic if you wish to ask this.