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. Database Connection Problem

Database Connection Problem

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 2.2k Views
  • 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.
  • bagavathikumarB Offline
    bagavathikumarB Offline
    bagavathikumar
    wrote on last edited by
    #1

    I am working in a database project using MYSQL with Qt. My application is connecting with database, If Qt and MySQL are in the same PC. But If I run my application from another PC and I am trying to connect to the database through ethernet, It is not connecting. This is my connection code:

    @ m_sqlDB = QSqlDatabase::addDatabase("QODBC");
    m_sqlDB.setDatabaseName("Driver={MySQL ODBC 5.1 Driver};Server=10.3.3.102;DATABASE=ADTL;");
    m_sqlDB.setUserName("root");
    m_sqlDB.setPassword("abcdef");

    if (!m_sqlDB.open()) {
        QMessageBox::critical(0, qApp->tr("Cannot open database"),
            qApp->tr("Unable to establish a database connection.\n"
                     "Click Cancel to exit."), QMessageBox::Cancel);
        return ;
    }@
    

    Kindly guide me, what i am missing.

    Thanks & Regards
    Bagavathikumar

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you deploy all needed dlls with your application on the other computer ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • bagavathikumarB Offline
        bagavathikumarB Offline
        bagavathikumar
        wrote on last edited by
        #3

        My application is working correctly, but the problem is in when i am calling the 'Open' API (QSqlDatabase). Basically my setup is like this:

        I have a two computers and both are connected to local intranet.

        Computer 1: I installed MySQL 5.5, MySQL ODBC 5.1 Driver and Qt 5.2. When I execute my code in this computer, The Application is connecting to the database without any problem.

        Computer 2: I installed only Qt 5.2. When I execute my code in this computer, the database Open API gets failed. Because Database is resides in Computer 1 and I am using IP address of Computer 1 in my code.

        Now I want to know whether I need to install ODBC driver in the Computer 2? or anything else is required to connect the remote database using ODBC method.

        1 Reply Last reply
        0
        • bagavathikumarB Offline
          bagavathikumarB Offline
          bagavathikumar
          wrote on last edited by
          #4

          Finally my application is connecting to the database, after install the MySQL ODBC 5.1 Driver in the Computer 2.

          But How do I ensure the required ODBC drivers are installed in the computer, when I deploy the application. Or what are the dll files required to include in my installation for ODBC?

          Thanks & Regards
          Bagavathikumar

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MisteKiste
            wrote on last edited by
            #5

            You mean the sql driver?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Also, did you setup your database to allow connection from other computers ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • bagavathikumarB Offline
                bagavathikumarB Offline
                bagavathikumar
                wrote on last edited by
                #7

                bq. You mean the sql driver?

                Yes

                bq. Also, did you setup your database to allow connection from other computers ?

                I've not done any setup. I installed the MYSQL 5.5 with MySQL ODBC 5.1 Driver in computer 1 and only MySQL ODBC 5.1 Driver in Computer 2.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Then check first that your database accepts connections from an external computer

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  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