Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT SQL DATABASE LOGIN
Qt 6.12 LTS is out! See what's new in the release blog

QT SQL DATABASE LOGIN

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 4 Posters 2.6k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #6

    Hi,

    That's the kind of constraints that should be done at the database level.
    Your database structure might also be too simple in the sense that if can be pretty easy to get duplicated data with small typos.

    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
    • GREYONG GREYON

      This part:```
      else
      {

          QSqlQuery qry;
      
      qry.prepare("INSERT INTO payments (SURNAME,LASTNAME,GRADE,CLASS,AMOUNT,DATE)"
                  "VALUES(:SURNAME, :LASTNAME, :GRADE, :CLASS, :AMOUNT,  :DATE)");
      
      qry.bindValue(":SURNAME",name);
      qry.bindValue(":GRADE",grade);
      qry.bindValue(":CLASS",clas);
      qry.bindValue(":AMOUNT",amount);
      qry.bindValue(":LASTNAME",receiver);
      qry.bindValue(":DATE",date);
      
      if(qry.exec())
          {
         QMessageBox::information(this,"inserted","PAYMENTS RECORDED SUCCESSFULLY!");
      
        }
      else
      

      {

         QMessageBox::warning(this,"warning","PAYMENT NOT RECORDED!");
      

      }
      }
      }
      }
      }

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #7

      @GREYON
      You should say what goes wrong? Do you get a compilation error? A runtime error? A message? If so, tell us what the message is. Something doesn't do what you expect? If so what, and how do you know? That's what's required for people to look at your issue!

      qry.prepare("INSERT INTO payments (SURNAME,LASTNAME,GRADE,CLASS,AMOUNT,DATE)"
                  "VALUES(:SURNAME, :LASTNAME, :GRADE, :CLASS, :AMOUNT,  :DATE)");
      

      Those two strings get joined. Look at them, and you will realize that will generate in the middle:

      ... CLASS,AMOUNT,DATE)VALUES(:SURNAME,
      

      The VALUES touches the parenthesis to its left, which is different from the sample code at https://doc.qt.io/qt-5/qsqlquery.html#approaches-to-binding-values. I don't know if that will be enough to error.

      In any case, when a query goes wrong (if that's what's happening), use https://doc.qt.io/qt-5/qsqlquery.html#lastError to print out the text of the error.

      1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        That's the kind of constraints that should be done at the database level.
        Your database structure might also be too simple in the sense that if can be pretty easy to get duplicated data with small typos.

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

        @SGaist
        Now what are you suggesting items of help?

        JonBJ SGaistS 2 Replies Last reply
        0
        • GREYONG GREYON

          @SGaist
          Now what are you suggesting items of help?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #9

          @GREYON

          In any case, when a query goes wrong (if that's what's happening), use https://doc.qt.io/qt-5/qsqlquery.html#lastError to print out the text of the error.

          Have you done this yet?

          GREYONG 1 Reply Last reply
          0
          • JonBJ JonB

            @GREYON

            In any case, when a query goes wrong (if that's what's happening), use https://doc.qt.io/qt-5/qsqlquery.html#lastError to print out the text of the error.

            Have you done this yet?

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

            @JonB
            Not yet,thanks let me go through it

            1 Reply Last reply
            0
            • GREYONG GREYON

              @SGaist
              Now what are you suggesting items of help?

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #11

              @GREYON said in QT SQL DATABASE LOGIN:

              @SGaist
              Now what are you suggesting items of help?

              What experience do you have with relational database design ?

              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

                @GREYON said in QT SQL DATABASE LOGIN:

                @SGaist
                Now what are you suggesting items of help?

                What experience do you have with relational database design ?

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

                @SGaist
                Not as experience as such,we let about it ,it was part of our course now we have a project.

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

                  Well, in that case you should start by learning a bit more about them before going further. At least take the time to go through Qt's SQL module documentation and examples.

                  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

                    Well, in that case you should start by learning a bit more about them before going further. At least take the time to go through Qt's SQL module documentation and examples.

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

                    @SGaist
                    Yeah,I think so

                    GREYONG 1 Reply Last reply
                    1
                    • GREYONG GREYON

                      @SGaist
                      Yeah,I think so

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

                      @GREYON
                      Thanks after going through Qsql documentation,the problem has been resolved

                      Christian EhrlicherC 1 Reply Last reply
                      0
                      • GREYONG GREYON

                        @GREYON
                        Thanks after going through Qsql documentation,the problem has been resolved

                        Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #16

                        @GREYON Then please mark this topic as solved, thx.

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        GREYONG 1 Reply Last reply
                        0
                        • Christian EhrlicherC Christian Ehrlicher

                          @GREYON Then please mark this topic as solved, thx.

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

                          @Christian-Ehrlicher
                          Okay , thanks for the information,but am new here,how can it mark as solved please?

                          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
                          • Unsolved