Using ODBC for MySQL Connection -> Error
General and Desktop
3
Posts
2
Posters
2.3k
Views
1
Watching
-
I try using ODBC for MySQL Connection -> Error.
I have an extern MySQL Server and the MySQL ODBC-Driver is installed and configured on my PC.C:\Users\chris\Desktop\musikkiosk\qt-anwendung\musikkiosk-build-desktop\debug\musikkiosk.exe...Failed to connect to root mysql admin
@
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC"); db.setDatabaseName("Driver={MySQL ODBC 5.1 Driver};DATABASE=_s0525289__kiosk;"); db.setUserName("s0525289"); db.setPassword("*****"); if (!db.open()) { qDebug() << "Failed to connect to root mysql admin"; return db; } else { return db; }@
-
Your connection string does not tell the driver where the server is, and you don't tell Qt either. It may default to localhost but I don't know.
If you look at QSqlDatabase::lastError() you might get a clue as to why it is failing.
There is a native Qt - MySQL connector but your school(?) environment may not have it installed.