Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. QMAKE
Qt 6.11 is out! See what's new in the release blog

QMAKE

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
27 Posts 6 Posters 4.7k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Did you check the myriad of forum posts related to building the MySQL plugin ?

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

    GREYONG 2 Replies Last reply
    0
    • SGaistS SGaist

      Hi,

      Did you check the myriad of forum posts related to building the MySQL plugin ?

      GREYONG Offline
      GREYONG Offline
      GREYON
      wrote on last edited by
      #3

      @SGaist
      I have not yet seen it

      1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Did you check the myriad of forum posts related to building the MySQL plugin ?

        GREYONG Offline
        GREYONG Offline
        GREYON
        wrote on last edited by
        #4

        @SGaist said in QMAKE:

        Hi,

        Did you check the myriad of forum posts related to building the MySQL plugin ?

        Do you have any link to that?You can help if you have

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #5

          See the docs: https://doc.qt.io/qt-5/sql-driver.html#qmysql-for-mysql-or-mariadb-5-and-higher

          section "How to Build the QMYSQL Plugin on Windows"

          (Z(:^

          GREYONG 1 Reply Last reply
          1
          • sierdzioS sierdzio

            See the docs: https://doc.qt.io/qt-5/sql-driver.html#qmysql-for-mysql-or-mariadb-5-and-higher

            section "How to Build the QMYSQL Plugin on Windows"

            GREYONG Offline
            GREYONG Offline
            GREYON
            wrote on last edited by
            #6

            @sierdzio thanks. Is it okay to use wampserve with qt application? Can it work properly?

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

              Hi,

              @GREYON said in QMAKE:

              wampserve

              It's a MySQL stack, as long as you have the MySQL plugin, no problem.

              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
              1
              • GREYONG Offline
                GREYONG Offline
                GREYON
                wrote on last edited by
                #8

                Thanks for that.am trying to build mysql plugins using the instructions from qt documentation.But when i download mysql server all what i see is a .exe file which think its a setup but i cannont see the lib and the c connector shown in the example below where am i getting it wrong? am i downloading wrong mysql server or what?

                Capture6.PNG

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

                  Well, the download provided by Oracle will be an installer. Nothing stops you from getting an older version of the connector if that simplify your life. The MariaDB connector is also a good alternative.

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

                  GREYONG 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Well, the download provided by Oracle will be an installer. Nothing stops you from getting an older version of the connector if that simplify your life. The MariaDB connector is also a good alternative.

                    GREYONG Offline
                    GREYONG Offline
                    GREYON
                    wrote on last edited by
                    #10

                    @SGaist said in QMAKE:

                    Well, the download provided by Oracle will be an installer. Nothing stops you from getting an older version of the connector if that simplify your life. The MariaDB connector is also a good alternative.

                    Thanks

                    1 Reply Last reply
                    0
                    • GREYONG Offline
                      GREYONG Offline
                      GREYON
                      wrote on last edited by
                      #11

                      what could be the meaning of the last two lines of this error?

                      Capture7.PNG

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

                        You are storing a local QSqlDatabase object and are recreating a new connection that is replacing the one stored in the variable.

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

                        GREYONG 1 Reply Last reply
                        1
                        • SGaistS SGaist

                          You are storing a local QSqlDatabase object and are recreating a new connection that is replacing the one stored in the variable.

                          GREYONG Offline
                          GREYONG Offline
                          GREYON
                          wrote on last edited by
                          #13

                          @SGaist So how can it be solved?

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

                            First thing, as the QSqlDatabase documentation explains: do not do that and if you remove the database connection, follow the documentation of the removeDatabase method..

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

                            GREYONG 1 Reply Last reply
                            1
                            • SGaistS SGaist

                              First thing, as the QSqlDatabase documentation explains: do not do that and if you remove the database connection, follow the documentation of the removeDatabase method..

                              GREYONG Offline
                              GREYONG Offline
                              GREYON
                              wrote on last edited by
                              #15

                              @SGaist

                              Thanks,I gone through that documention,but still not clear,I uninstalled the mysql server which was connected to the app at first,but after trying to connect for second ,am facing that error.
                              The first connection used the default connection name. Am confused on how to desconnect the database with a default name.I have seen this function QSqldatabase::connectionName() but on how to use it am not sure.Please any help will be appreciated.

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

                                How are you using QSqlDatabase in your code ?

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

                                GREYONG 1 Reply Last reply
                                0
                                • SGaistS SGaist

                                  How are you using QSqlDatabase in your code ?

                                  GREYONG Offline
                                  GREYONG Offline
                                  GREYON
                                  wrote on last edited by
                                  #17

                                  @SGaist
                                  Here is the code:

                                  QT       += core gui sql printsupport
                                  
                                  
                                  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
                                  
                                  CONFIG += c++11
                                  
                                  

                                  .h file

                                  #ifndef MAINWINDOW_H
                                  #define MAINWINDOW_H
                                  
                                  #include <QMainWindow>
                                  #include<QtSql>
                                  #include<QSqlDatabase>
                                  #include<QMessageBox>
                                  #include<mywork.h>
                                  //#include<payfee.h>
                                  
                                  QT_BEGIN_NAMESPACE
                                  namespace Ui { class MainWindow; }
                                  QT_END_NAMESPACE
                                  
                                  class MainWindow : public QMainWindow
                                  {
                                      Q_OBJECT
                                  
                                  public:
                                      MainWindow(QWidget *parent = nullptr);
                                      ~MainWindow();
                                      void closedb();
                                  
                                  
                                  private slots:
                                      void on_LOGIN_clicked();
                                  
                                      void on_REGISTER_clicked();
                                  
                                      void on_LOGIN_2_clicked();
                                  
                                  private:
                                      Ui::MainWindow *ui;
                                  QSqlDatabase database;
                                  
                                  
                                  };
                                  #endif // MAINWINDOW_H
                                  
                                  

                                  d.cpp file

                                  #include "mainwindow.h"
                                  #include "ui_mainwindow.h"
                                  
                                  
                                  MainWindow::MainWindow(QWidget *parent)
                                      : QMainWindow(parent)
                                      , ui(new Ui::MainWindow)
                                  {
                                      ui->setupUi(this);
                                      ui->USERNAME_REG->setPlaceholderText("ENTER USERNAME");
                                      ui->E_MAIL->setPlaceholderText("ENTER YOUR E-MAIL ADDRESS");
                                      ui->PASSWORD_REG->setPlaceholderText("ENTER YOUR PASSWORD");
                                      ui->PHONE->setPlaceholderText("ENTER PHONE NUMBER");
                                      ui->USERNAME_LOGIN->setPlaceholderText("ENTER USERNAME");
                                      ui->PASSWORD_LOGIN->setPlaceholderText("ENTER PASSWORD");
                                  
                                  
                                  }
                                  
                                  MainWindow::~MainWindow()
                                  {
                                      delete ui;
                                  }
                                  
                                  
                                  void MainWindow::on_LOGIN_clicked()
                                  {
                                  
                                  QSqlDatabase db=QSqlDatabase::addDatabase("QMYSQL");
                                  db.setHostName("127.0.0.1");
                                  db.setUserName("root");
                                  db.setPassword("");
                                  db.setDatabaseName("mysql");
                                  
                                  if(db.open())  //database connections
                                   {
                                   QMessageBox::information(this,"connection","SYSTEM READY\nYOU CAN NOW REGISTER OR LOGIN!");
                                  
                                  }
                                  else {
                                  QMessageBox::information(this,"not connected","SYSTEM NOT CONNECTED");
                                  }
                                  
                                  }
                                  
                                  
                                  
                                  
                                  void MainWindow::on_REGISTER_clicked()
                                  {
                                      QString username = ui->USERNAME_REG->text();
                                      QString email=ui->E_MAIL->text();
                                      QString password =ui->PASSWORD_REG->text();
                                      QString phone =ui->PHONE->text();
                                  
                                      if(username=="" || email==""|| password==""||phone=="")
                                      {
                                  
                                        QMessageBox::warning(this,"warning","PLEASE ENTER ALL THE REQUIRED DETAILS");
                                      }
                                      else
                                        {//checking to avoid duplication of data
                                          QSqlQuery query;
                                          query.prepare("SELECT USERNAME,EMAIL,PHONE FROM users WHERE USERNAME=:USERNAME AND EMAIL=:EMAIL AND PHONE=:PHONE");
                                  
                                             query.bindValue(":USERNAME",username);
                                              query.bindValue(":EMAIL",email);
                                              query.bindValue(":PHONE",phone);
                                  
                                           if(query.exec()){
                                  
                                                  //QMessageBox::warning(this,"warninng","query successful!");
                                                   }
                                          if(query.size()>0){
                                  
                                                  QMessageBox::warning(this,"WARNING","CHECK YOUR NAME,E-MAIL OR PHONE NUMBER PLEASE\n"
                                                                                "ONE OF THESE HAVE BEEN USED BY OTHER USERS ALREADY!");
                                  
                                          }
                                             // QSqlQuery qry;
                                          else
                                                {
                                      //running insert query
                                  
                                      QSqlQuery qry;
                                  
                                      qry.prepare("INSERT INTO users(USERNAME,EMAIL,PASSWORD,PHONE)"
                                                  "VALUES(:USERNAME, :EMAIL, :PASSWORD, :PHONE)");
                                  
                                      qry.bindValue(":USERNAME",username);
                                      qry.bindValue(":EMAIL",email);
                                      qry.bindValue(":PASSWORD",password);
                                      qry.bindValue(":PHONE",phone);
                                  
                                      if(qry.exec())
                                          {
                                         QMessageBox::information(this,"WELCOME","YOU HAVE SUCCESSFULLY REGISTERED!\nYOU NOW LOGIN!");
                                  
                                        }
                                      else
                                     {
                                  
                                         QMessageBox::warning(this,"WARNING!","PLEASE TURN ON THE SYSTEM!");
                                  
                                  }
                                  
                                  }
                                  
                                  }
                                  }
                                  void MainWindow::on_LOGIN_2_clicked()
                                  {
                                      QString username=ui->USERNAME_LOGIN->text();
                                      QString password=ui->PASSWORD_LOGIN->text();
                                     QSqlQuery query(QSqlDatabase::database("Myconnect"));
                                  
                                     query.prepare("SELECT USERNAME,PASSWORD FROM users WHERE USERNAME=:USERNAME AND PASSWORD=:PASSWORD");
                                  
                                        query.bindValue(":USERNAME",username);
                                         query.bindValue(":PASSWORD",password);
                                  
                                      if(!query.exec()){
                                  
                                             //QMessageBox::warning(this,"warninng","PLEASE TURN ON THE SYSTEM!");
                                              }
                                     if(query.size()>0){
                                       //window two
                                       hide();
                                       MYWORK work;
                                       work.setModal(true);
                                       work.exec();
                                  
                                      }
                                      else
                                         {
                                         QMessageBox::warning(this,"CHENJEZO!","NOT SUCCESSFUL!\n"
                                                                               "TURN ON THE SYSTEM OR ENTER CORRECT DETAILS!");
                                  
                                     }
                                  
                                       }
                                  
                                  jsulmJ 1 Reply Last reply
                                  0
                                  • GREYONG GREYON

                                    @SGaist
                                    Here is the code:

                                    QT       += core gui sql printsupport
                                    
                                    
                                    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
                                    
                                    CONFIG += c++11
                                    
                                    

                                    .h file

                                    #ifndef MAINWINDOW_H
                                    #define MAINWINDOW_H
                                    
                                    #include <QMainWindow>
                                    #include<QtSql>
                                    #include<QSqlDatabase>
                                    #include<QMessageBox>
                                    #include<mywork.h>
                                    //#include<payfee.h>
                                    
                                    QT_BEGIN_NAMESPACE
                                    namespace Ui { class MainWindow; }
                                    QT_END_NAMESPACE
                                    
                                    class MainWindow : public QMainWindow
                                    {
                                        Q_OBJECT
                                    
                                    public:
                                        MainWindow(QWidget *parent = nullptr);
                                        ~MainWindow();
                                        void closedb();
                                    
                                    
                                    private slots:
                                        void on_LOGIN_clicked();
                                    
                                        void on_REGISTER_clicked();
                                    
                                        void on_LOGIN_2_clicked();
                                    
                                    private:
                                        Ui::MainWindow *ui;
                                    QSqlDatabase database;
                                    
                                    
                                    };
                                    #endif // MAINWINDOW_H
                                    
                                    

                                    d.cpp file

                                    #include "mainwindow.h"
                                    #include "ui_mainwindow.h"
                                    
                                    
                                    MainWindow::MainWindow(QWidget *parent)
                                        : QMainWindow(parent)
                                        , ui(new Ui::MainWindow)
                                    {
                                        ui->setupUi(this);
                                        ui->USERNAME_REG->setPlaceholderText("ENTER USERNAME");
                                        ui->E_MAIL->setPlaceholderText("ENTER YOUR E-MAIL ADDRESS");
                                        ui->PASSWORD_REG->setPlaceholderText("ENTER YOUR PASSWORD");
                                        ui->PHONE->setPlaceholderText("ENTER PHONE NUMBER");
                                        ui->USERNAME_LOGIN->setPlaceholderText("ENTER USERNAME");
                                        ui->PASSWORD_LOGIN->setPlaceholderText("ENTER PASSWORD");
                                    
                                    
                                    }
                                    
                                    MainWindow::~MainWindow()
                                    {
                                        delete ui;
                                    }
                                    
                                    
                                    void MainWindow::on_LOGIN_clicked()
                                    {
                                    
                                    QSqlDatabase db=QSqlDatabase::addDatabase("QMYSQL");
                                    db.setHostName("127.0.0.1");
                                    db.setUserName("root");
                                    db.setPassword("");
                                    db.setDatabaseName("mysql");
                                    
                                    if(db.open())  //database connections
                                     {
                                     QMessageBox::information(this,"connection","SYSTEM READY\nYOU CAN NOW REGISTER OR LOGIN!");
                                    
                                    }
                                    else {
                                    QMessageBox::information(this,"not connected","SYSTEM NOT CONNECTED");
                                    }
                                    
                                    }
                                    
                                    
                                    
                                    
                                    void MainWindow::on_REGISTER_clicked()
                                    {
                                        QString username = ui->USERNAME_REG->text();
                                        QString email=ui->E_MAIL->text();
                                        QString password =ui->PASSWORD_REG->text();
                                        QString phone =ui->PHONE->text();
                                    
                                        if(username=="" || email==""|| password==""||phone=="")
                                        {
                                    
                                          QMessageBox::warning(this,"warning","PLEASE ENTER ALL THE REQUIRED DETAILS");
                                        }
                                        else
                                          {//checking to avoid duplication of data
                                            QSqlQuery query;
                                            query.prepare("SELECT USERNAME,EMAIL,PHONE FROM users WHERE USERNAME=:USERNAME AND EMAIL=:EMAIL AND PHONE=:PHONE");
                                    
                                               query.bindValue(":USERNAME",username);
                                                query.bindValue(":EMAIL",email);
                                                query.bindValue(":PHONE",phone);
                                    
                                             if(query.exec()){
                                    
                                                    //QMessageBox::warning(this,"warninng","query successful!");
                                                     }
                                            if(query.size()>0){
                                    
                                                    QMessageBox::warning(this,"WARNING","CHECK YOUR NAME,E-MAIL OR PHONE NUMBER PLEASE\n"
                                                                                  "ONE OF THESE HAVE BEEN USED BY OTHER USERS ALREADY!");
                                    
                                            }
                                               // QSqlQuery qry;
                                            else
                                                  {
                                        //running insert query
                                    
                                        QSqlQuery qry;
                                    
                                        qry.prepare("INSERT INTO users(USERNAME,EMAIL,PASSWORD,PHONE)"
                                                    "VALUES(:USERNAME, :EMAIL, :PASSWORD, :PHONE)");
                                    
                                        qry.bindValue(":USERNAME",username);
                                        qry.bindValue(":EMAIL",email);
                                        qry.bindValue(":PASSWORD",password);
                                        qry.bindValue(":PHONE",phone);
                                    
                                        if(qry.exec())
                                            {
                                           QMessageBox::information(this,"WELCOME","YOU HAVE SUCCESSFULLY REGISTERED!\nYOU NOW LOGIN!");
                                    
                                          }
                                        else
                                       {
                                    
                                           QMessageBox::warning(this,"WARNING!","PLEASE TURN ON THE SYSTEM!");
                                    
                                    }
                                    
                                    }
                                    
                                    }
                                    }
                                    void MainWindow::on_LOGIN_2_clicked()
                                    {
                                        QString username=ui->USERNAME_LOGIN->text();
                                        QString password=ui->PASSWORD_LOGIN->text();
                                       QSqlQuery query(QSqlDatabase::database("Myconnect"));
                                    
                                       query.prepare("SELECT USERNAME,PASSWORD FROM users WHERE USERNAME=:USERNAME AND PASSWORD=:PASSWORD");
                                    
                                          query.bindValue(":USERNAME",username);
                                           query.bindValue(":PASSWORD",password);
                                    
                                        if(!query.exec()){
                                    
                                               //QMessageBox::warning(this,"warninng","PLEASE TURN ON THE SYSTEM!");
                                                }
                                       if(query.size()>0){
                                         //window two
                                         hide();
                                         MYWORK work;
                                         work.setModal(true);
                                         work.exec();
                                    
                                        }
                                        else
                                           {
                                           QMessageBox::warning(this,"CHENJEZO!","NOT SUCCESSFUL!\n"
                                                                                 "TURN ON THE SYSTEM OR ENTER CORRECT DETAILS!");
                                    
                                       }
                                    
                                         }
                                    
                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #18

                                    @GREYON said in QMAKE:

                                    QSqlDatabase database;

                                    As suggested already remove that (you do not even use it in the code you posted).
                                    There is no need to keep QSqlDatabase instance (explained in the documentation).

                                    QSqlQuery query(QSqlDatabase::database("Myconnect")); - where do you actually add this database? Please read https://doc.qt.io/qt-5/qsqldatabase.html#database
                                    "If no connectionName is specified the default connection is used. If connectionName does not exist in the list of databases, an invalid connection is returned."
                                    "

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    GREYONG 1 Reply Last reply
                                    2
                                    • jsulmJ jsulm

                                      @GREYON said in QMAKE:

                                      QSqlDatabase database;

                                      As suggested already remove that (you do not even use it in the code you posted).
                                      There is no need to keep QSqlDatabase instance (explained in the documentation).

                                      QSqlQuery query(QSqlDatabase::database("Myconnect")); - where do you actually add this database? Please read https://doc.qt.io/qt-5/qsqldatabase.html#database
                                      "If no connectionName is specified the default connection is used. If connectionName does not exist in the list of databases, an invalid connection is returned."
                                      "

                                      GREYONG Offline
                                      GREYONG Offline
                                      GREYON
                                      wrote on last edited by
                                      #19

                                      @jsulm
                                      Thanks for your help .The Qsqldatabase database has been used in a difference class when calling for the instance database.But the main problem is that I can't connect to the database any more .am always told qmsql drivers not loaded.old connection removed.My am is to remove that old
                                      connectionn so that I can connect to the database again.

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

                                        But why do you need to remove the connection in the first place ? Can't you just close it, update the information and open it again ?

                                        How exactly are you using QSqlDatabase ?

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

                                        GREYONG 1 Reply Last reply
                                        0
                                        • SGaistS SGaist

                                          But why do you need to remove the connection in the first place ? Can't you just close it, update the information and open it again ?

                                          How exactly are you using QSqlDatabase ?

                                          GREYONG Offline
                                          GREYONG Offline
                                          GREYON
                                          wrote on last edited by
                                          #21

                                          @SGaist
                                          I don't really want to remove the connection,its like it became unconnected when i unistalled qt5 .9.9 and installal qt 5.12.5, i tried to install qt 5.9.9 but it did not become connected again.

                                          on how QSqlDatabase is being used,It was used to create an object database which is being called when i want to access the database .below is an example of how it has been used.

                                          private slots:
                                              void on_LOGIN_clicked();
                                          
                                              void on_REGISTER_clicked();
                                          
                                              void on_LOGIN_2_clicked();
                                          
                                          private:
                                              Ui::MainWindow *ui;
                                          QSqlDatabase database;
                                          
                                          

                                          MUSIC, CLASS.

                                          #include "music.h"
                                          #include "ui_music.h"
                                          
                                          MUSIC::MUSIC(QWidget *parent) :
                                              QDialog(parent),
                                              ui(new Ui::MUSIC)
                                          {
                                              ui->setupUi(this);
                                              ui->SURNAME->setPlaceholderText("ENTER SURNAME");
                                              ui->GRADE->setPlaceholderText("INTER GRADE, e.g  9");
                                              ui->CLASS->setPlaceholderText("ENTER CLASS  e.g 9A");
                                              ui->AMOUNT->setPlaceholderText("ENTER AMOUNT e.g 100");
                                              ui->OTHERNAME->setPlaceholderText("ENTER OTHER NAME(S)");
                                          }
                                          
                                          MUSIC::~MUSIC()
                                          {
                                              delete ui;
                                          }
                                          
                                          void MUSIC::on_ENTER_FEE_clicked()
                                          {
                                              QString surname =ui->SURNAME->text();
                                              QString lastname=ui->OTHERNAME->text();
                                              QString clas= ui->CLASS->text();
                                              QString amount=ui->AMOUNT->text();
                                              QString grade =ui->GRADE->text();
                                              QString date=ui->DATE->text();
                                          
                                              if(surname=="" || grade==""|| clas==""||amount==""||lastname==""||date=="")
                                              {
                                          
                                                QMessageBox::warning(this,"warning","PLEASE ENTER ALL THE REQUIRED DETAILS");
                                              }
                                              else
                                                {
                                          
                                           QSqlDatabase::database();
                                           QSqlQuery query;
                                           query.prepare("SELECT SURNAME,LASTNAME FROM music WHERE SURNAME=:surname AND LASTNAME=:lastname");
                                          
                                              query.bindValue(":surname",surname);
                                               query.bindValue(":lastname",lastname);
                                          
                                            if(query.exec()){
                                          
                                                   //QMessageBox::warning(this,"warninng","query successful!");
                                                    }
                                           if(query.size()>0){
                                          
                                                   QMessageBox::warning(this,"WARNING","THE NAME HAS BEEN ENTERED ALREADY!\nUSE INITIAL IF ITS A DIFFERENT NAME!");
                                                          }
                                          
                                              // QSqlQuery qry;
                                                     else
                                                        {
                                              query.prepare("INSERT INTO music (SURNAME,LASTNAME,GRADE,CLASS,AMOUNT,DATE)"
                                          
                                                          "VALUES(:SURNAME, :LASTNAME, :GRADE, :CLASS, :AMOUNT,  :DATE)");
                                          
                                              query.bindValue(":SURNAME",surname);
                                              query.bindValue(":GRADE",grade);
                                              query.bindValue(":CLASS",clas);
                                              query.bindValue(":AMOUNT",amount);
                                              query.bindValue(":LASTNAME",lastname);
                                              query.bindValue(":DATE",date);
                                          
                                              if(query.exec())
                                                  {
                                                 QMessageBox::information(this,"inserted","PAYMENTS RECORDED SUCCESSFULLY!");
                                          
                                                }
                                              else
                                             {
                                          
                                                 QMessageBox::warning(this,"warning","PAYMENT NOT RECORDED!");
                                          
                                            }
                                             }
                                          
                                          }
                                          }
                                          
                                          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