QT (windowsxp) MSQL configuration failure complete

Source: Internet
Author: User

The most in the test of a project using MySQL database, QT How to use MySQL, online search again, the answer is different, the group asked again, the results of the answer is fur, can not solve the problem, now their own failure to reproduce, so that the future of the suffering from purgatory.

1, Project: My project was developed by QT4.5, using MySQL database.

2, Environment: My development environment is: WINDOWS XP SP2 my QT tool is QT5.7 latest debug MinGW editor Qt creator 4. 4, did not use the VS version of the online said QT5. 7 does not support XP but the test results are not so, the official website did not find 5. 7 version with XP but the actual use of MinGW, completely can work in XP without any problems.

2 Upgrade: Just said, the eye-catching is QT4. 5 The project needs to be QT5. 7-in-turn reconfiguration but this is not a lot of difficulty, you can see the previous blog post QT upgrade.

Software startup prompt after Upgrade:

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/86/CC/wKioL1fLbeSxUYM3AAAngTRHEGU078.jpg-wh_500x0-wm_3 -wmp_4-s_1411560181.jpg "title=" 333.JPG "alt=" Wkiol1flbesxuym3aaangtrhegu078.jpg-wh_50 "/>

3 Follow the instructions that are not MySQL database driven so to

D:\Qt\Qt5.7.0\5.7\mingw53_32\plugins\sqldrivers (This is my Qt installation directory for individuals with different)

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/86/CD/wKiom1fLbxzzisghAA444a_yCJQ042.gif-wh_500x0-wm_3 -wmp_4-s_1473461438.gif "title=" 44444.gif "alt=" Wkiom1flbxzzisghaa444a_ycjq042.gif-wh_50 "/>


650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/86/CC/wKioL1fLb8qTc5hQAAC9EVjYCN0986.jpg-wh_500x0-wm_3 -wmp_4-s_2600745821.jpg "title=" 555.JPG "alt=" Wkiol1flb8qtc5hqaac9evjycn0986.jpg-wh_50 "/>


Obviously see yourself in the directory with MySQL driver plugin


But is not able to connect, in fact, MySQL belongs to the third party service itself does not have in QT included here just provide a connection interface, since this shows that we also need third-party software MySQL

So to download the website, MYSQL5. 7 new better, results test still can't connect

  

#include <QCoreApplication>

#include <QtSql/QSql>

#include <QSql>

#include <QSqlDatabase>

#include <QSqlQuery>

#include <QDebug>

#include <QVariant>

#include <QWidget>

#include <QMessageBox>

#include <QSqlError>


int main (int argc, char *argv[])

{

Qcoreapplication A (argc, argv);

Qsqldatabase db= qsqldatabase::adddatabase ("Qmysql");//qsqlite

Db.setdatabasename (": Memory:");

if (!db.open ())

// {

return false;

//}

/*

Qsqlquery query;

Query.exec ("CREATE TABLE student (ID int primary key,name varchar)");

Query.exec ("INSERT into student value (' 1,xiaogang ')");

Query.exec ("INSERT into student value (' 2,wangwu ')");

Query.exec ("INSERT into student value (' 3,lisi ')");


Query.exec ("Slect ID name from student where Id>2");

while (Query.next ())

{

int Ele0=query.value (0). ToInt ();


QString Ele1=query.value (1). ToString ();

Qdebug () << ele0 << ele1;

}

*/

/*

Qsqldatabase db = Qsqldatabase::adddatabase ("Qmysql");

Db.sethostname ("127.0.0.1");

Db.setdatabasename ("Testsql");

Db.setusername ("root");

Db.setpassword ("root");

bool OK = Db.open ();

Qdebug () << OK;


Hostname=localhost

Database=bpmstest

Username=root

password=123456

*/


Qsqldatabase db = Qsqldatabase::adddatabase ("Qmysql");

Db.sethostname ("127.0.0.1");//localhost

Db.setport (3306);

Db.setdatabasename ("Testsql");

Db.setusername ("root");

Db.setpassword ("123456");


bool OK = Db.open ();//Antigen Rainbow Hygiene Indent version credential Samuel Sports 繛 鎺?


if (!ok)

{

Qmessagebox::critical (0,qobject::tr ("HTTP failed failed indent version credential Samuel name けます Lu ワ dev 锛 lih dev"), Db.lasterror (). text ());

Qdebug () << OK;

return false;

}

Else

{

Qmessagebox::information (0,qobject::tr ("Tips"), Qobject::tr ("HTTP failed failed indent version credential Samuel result Yao Animals Juanjuan dev 锛 lih dev"));

Qdebug () << ok<<123;

return true;

}

Eyewear ã lower æ 愮 identify xixi cen ryon June weight? 锛?





return A.exec ();

}


It seems necessary to install MySQL so download and install MySQL installed after the results do not know that is the MySQL startup item

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/86/CC/wKioL1fLcrfCcC_mAAFFB0DX61M592.jpg-wh_500x0-wm_3 -wmp_4-s_445230182.jpg "title=" 666.JPG "alt=" Wkiol1flcrfccc_maaffb0dx61m592.jpg-wh_50 "/>

4 you have MySQL database in your environment.

and start your own software.

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/86/CD/wKiom1fLc-WA0iVfAABssyu-KnQ962.jpg-wh_500x0-wm_3 -wmp_4-s_81647204.jpg "title=" 777.JPG "alt=" Wkiom1flc-wa0ivfaabssyu-knq962.jpg-wh_50 "/>





QT (windowsxp) MSQL configuration failure complete

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.