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. Deleting row from MySQL database
Forum Updated to NodeBB v4.3 + New Features

Deleting row from MySQL database

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 5 Posters 6.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.
  • V Offline
    V Offline
    veera
    wrote on last edited by
    #5

    Hi
    I am inserting a integer number using qlineedit like this
    "int contact_no = ui->lineEdit_3->text().toInt();
    query->addBindValue(contact_no);" now my problem is it is accepting only 9 digit numbers only not more than that 10 ,11,etc .please tell which data type i need to use if want give more than 9 digits number ......

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #6

      what type is id in your database?

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      V 1 Reply Last reply
      2
      • V Offline
        V Offline
        veera
        wrote on last edited by
        #7

        int type

        jsulmJ 1 Reply Last reply
        0
        • V veera

          int type

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #8

          @veera Can you show the CREATE TABLE query you're using for the table where you're trying to insert int > 9digits?

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

          V 1 Reply Last reply
          0
          • VRoninV VRonin

            what type is id in your database?

            V Offline
            V Offline
            veera
            wrote on last edited by VRonin
            #9

            @VRonin said in Deleting row from MySQL database:

            what type is id in your database?

            int type only......

            1 Reply Last reply
            0
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #10

              int in MySQL goes from -2147483648 to 2147483647 (or from 0 to 4294967295 if unsigned) (ref: https://dev.mysql.com/doc/refman/5.7/en/integer-types.html) and same goes for a c++ int variable in most environments so it's only natural you can't use the majority of numbers with 10 digits.

              Use a BIGINT (qint64 in C++) to go to 18 digits or just use a string

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              V 1 Reply Last reply
              2
              • jsulmJ jsulm

                @veera Can you show the CREATE TABLE query you're using for the table where you're trying to insert int > 9digits?

                V Offline
                V Offline
                veera
                wrote on last edited by
                #11

                @jsulm
                Here is my table
                CREATE TABLE entry (id INT,name NVARCHAR(200),contact_no INT,lastname NVARCHAR(200),emailid NVARCHAR(200));

                jsulmJ 1 Reply Last reply
                0
                • V veera

                  @jsulm
                  Here is my table
                  CREATE TABLE entry (id INT,name NVARCHAR(200),contact_no INT,lastname NVARCHAR(200),emailid NVARCHAR(200));

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  @veera See explanation from @VRonin

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

                  1 Reply Last reply
                  0
                  • VRoninV VRonin

                    int in MySQL goes from -2147483648 to 2147483647 (or from 0 to 4294967295 if unsigned) (ref: https://dev.mysql.com/doc/refman/5.7/en/integer-types.html) and same goes for a c++ int variable in most environments so it's only natural you can't use the majority of numbers with 10 digits.

                    Use a BIGINT (qint64 in C++) to go to 18 digits or just use a string

                    V Offline
                    V Offline
                    veera
                    wrote on last edited by
                    #13

                    @VRonin
                    I am using MSSQL on ubuntu 16.04 LTS 64 bit
                    after using qint64 instead of int in qtcreator application..... also samething is coming i.e 0 if i am inserting more than 10 digits....

                    jsulmJ 1 Reply Last reply
                    0
                    • V veera

                      @VRonin
                      I am using MSSQL on ubuntu 16.04 LTS 64 bit
                      after using qint64 instead of int in qtcreator application..... also samething is coming i.e 0 if i am inserting more than 10 digits....

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #14

                      @veera You need to change the data type of id in your database (BIGINT as @VRonin already said) , not just use qint64 in your code.
                      Why do you need such big numbers?

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

                      1 Reply Last reply
                      1
                      • V Offline
                        V Offline
                        veera
                        wrote on last edited by veera
                        #15

                        i want to store the mobile No is 10 digits so after declaring qint64 also same issue is coming ....

                        mrjjM 1 Reply Last reply
                        0
                        • V veera

                          i want to store the mobile No is 10 digits so after declaring qint64 also same issue is coming ....

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #16

                          @veera
                          Hi
                          int contact_no = ui->lineEdit_3->text().toInt();

                          This is still int and limit in range

                          So you are looking at something like

                          bool ok;
                          QString input=ui->lineEdit_3->text();// take text
                          qint64 contact_no = input.toLongLong(&ok); // convert
                          if (!ok) {
                          error("invalid value");
                          return;
                          }
                          ..
                          Convert was ok, use.

                          1 Reply Last reply
                          4

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved