Using ODBC for MySQL Connection -> Error
-
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.
-
the error was that the odbc driver on my pc diddn't work
yeah on my university i cant use mysql connector!