Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using ODBC for MySQL Connection -> Error

Using ODBC for MySQL Connection -> Error

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Furtano
    wrote on last edited by
    #1

    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;
    }
    

    @

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Furtano
        wrote on last edited by
        #3

        the error was that the odbc driver on my pc diddn't work

        yeah on my university i cant use mysql connector!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved