Database Connection Problem
-
wrote on 26 Feb 2015, 11:16 last edited by
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 -
Hi,
Did you deploy all needed dlls with your application on the other computer ?
-
wrote on 27 Feb 2015, 06:59 last edited by
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.
-
wrote on 27 Feb 2015, 08:16 last edited by
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 -
wrote on 27 Feb 2015, 14:31 last edited by
You mean the sql driver?
-
Also, did you setup your database to allow connection from other computers ?
-
wrote on 28 Feb 2015, 12:30 last edited by
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.
-
Then check first that your database accepts connections from an external computer
7/8