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. Qsqlite<--->sqlite3 qt5 select problem....lasterror return nothings ....

Qsqlite<--->sqlite3 qt5 select problem....lasterror return nothings ....

Scheduled Pinned Locked Moved Solved General and Desktop
11 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.
  • gfxxG Offline
    gfxxG Offline
    gfxx
    wrote on last edited by
    #1
    QSqlQuery Cset(db);
        Cset.prepare("SELECT a, b, c, a1, b1, c1, d, canny, e, f, g, h, nomepgr, m, n, o, p, q, gap, ip, port, mask, gain, exposure_abs, exposure, brightness, contrast, hue, saturation, white, framerate, autowhite, autogain, autoexposure, matrixptax, matrixptay, matrixptbx, matrixptby, matrixptcx, matrixptcy, matrixptdx, matrixptdy, rectax, rectay, rectbx, rectby, line, offsetxm, offsetym  FROM val_chan WHERE id_val =:id_val");
        Cset.bindValue(":id_val", ricId); /*** ricId is an integer****/
        Cset.exec();
        if( !Cset.exec() ) {qDebug() << "somethings is wrong ....";} /**** return always these messages*********/
    
    yesterday these select work perfet ... but today I have add some new colum in table ...13 new colum ... and the select not work at all .... a try a lot of trik but nothings.... cset.lasterror return nothings ....
    
    regards
    Giorgio
    

    bkt

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2
      Cset.exec(); // <- delete this line
         if( !Cset.exec() )
      

      "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

      1 Reply Last reply
      2
      • T Offline
        T Offline
        Tschikkn
        wrote on last edited by
        #3

        Hi!

        The first thing to check is the returning error value (if any) from QSqlQuery. Just change your qDebug-line to

        if( !Cset.exec() ) {qDebug() << "somethings is wrong ...." << Cset.lastError().text();}
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by SGaist
          #4

          Hi,

          You should print the error returned by Cset to see what is going on.

          Out of curiosity, what's the size of that table ? What should it contain ?

          [edit]: @VRonin's right, you're executing your query twice.

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

          gfxxG 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            You should print the error returned by Cset to see what is going on.

            Out of curiosity, what's the size of that table ? What should it contain ?

            [edit]: @VRonin's right, you're executing your query twice.

            gfxxG Offline
            gfxxG Offline
            gfxx
            wrote on last edited by gfxx
            #5

            @ ALL ... thank for reply .....

            firstly : ok 2time cset is only last try errer ...
            second: i try other time to get lasterror ... never when i have add while cicle .... so now I get these error:

            QSqlError("", "Parameter count mismatch", "")
            

            so I try to change in these way ....

            QSqlQuery Cset(db);
                Cset.prepare("SELECT a, b, c, a1, b1, c1, d, canny, e, f, g, h, nomepgr, m, n, o, p, q, gap, ip, port, mask, gain, exposure_abs, exposure, brightness, contrast, hue, saturation, white, framerate, autowhite, autogain, autoexposure, matrixptax, matrixptay, matrixptbx, matrixptby, matrixptcx, matrixptcy, matrixptdx, matrixptdy, rectax, rectay, rectbx, rectby, line, offsetxm, offsetym  FROM val_chan WHERE (:id_val)"); /*******<---- these change**********/
                Cset.bindValue(":id_val", ricId);
                if( !Cset.exec() ) {qDebug() << "somethings is wrong ....";qDebug() << Cset.lastError(); }
                while (Cset.next()) {
                    controlQuery ++;
                    qDebug() << "controlQuery ++:  " << controlQuery;
                a = Cset.value(0).toInt();
            

            nothings change .....

            @SGaist ... actually in the table there are only 10 row ... offsetxm, offsetym is real ... all other is integer and id_val obviusly is PKinteger ....

            regards
            giorgio

            bkt

            1 Reply Last reply
            0
            • T Offline
              T Offline
              Tschikkn
              wrote on last edited by
              #6

              Hi

              First: You are sure you wanr your SQL-WHERE-clause like "WHERE (:id_val)" and not as above "WHERE id_val =:id_val"?

              Second: Parameter mismatch usually means that your query is wrong. Check if all fieldnames are correct or provide us a database scheme if this doesn't help.

              gfxxG 1 Reply Last reply
              1
              • T Tschikkn

                Hi

                First: You are sure you wanr your SQL-WHERE-clause like "WHERE (:id_val)" and not as above "WHERE id_val =:id_val"?

                Second: Parameter mismatch usually means that your query is wrong. Check if all fieldnames are correct or provide us a database scheme if this doesn't help.

                gfxxG Offline
                gfxxG Offline
                gfxx
                wrote on last edited by
                #7

                @Tschikkn Iread a pos where these problem was solved change "id_val = :id_val) to (:id_val) ......

                this is my table....

                CREATE TABLE val_chan (
                    "id_val" INTEGER NOT NULL,
                    "a" INTEGER,
                    "b" INTEGER,
                    "c" INTEGER,
                    "a1" INTEGER,
                    "b1" INTEGER,
                    "c1" INTEGER,
                    "d" INTEGER,
                    "canny" INTEGER,
                    "e" INTEGER,
                    "f" INTEGER,
                    "g" INTEGER,
                    "h" INTEGER,
                    "nomepgr" TEXT,
                    "m" INTEGER,
                    "n" INTEGER,
                    "o" INTEGER,
                    "p" INTEGER,
                    "q" INTEGER,
                    "gap" INTEGER,
                    "ip" TEXT,
                    "port" TEXT,
                    "mask" TEXT,
                    "gain" INTEGER,
                    "exposure_abs" INTEGER,
                    "exposure" INTEGER,
                    "brightness" INTEGER,
                    "contrast" INTEGER,
                    "hue" INTEGER,
                    "saturation" INTEGER,
                    "white" INTEGER,
                    "framerate" INTEGER,
                    "autowhite" INTEGER,
                    "autogain" INTEGER,
                    "autoexposure" INTEGER,
                    "matrixptax" INTEGER,
                    "matrixptay" INTEGER,
                    "martixptbx" INTEGER,
                    "matrixptby" INTEGER,
                    "matrixptcx" INTEGER,
                    "matrixptcy" INTEGER,
                    "matrixptdx" INTEGER,
                    "matrixptdy" INTEGER,
                    "rectax" INTEGER,
                    "rectay" INTEGER,
                    "rectbx" INTEGER,
                    "rectby" INTEGER,
                    "line" INTEGER,
                    "offsetxm" REAL,
                    "offsetym" REAL
                

                Regards
                giorgio

                bkt

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

                  if you are getting all the fields anyway you can use "SELECT * FROM val_chan WHERE id_val = :id_val" and ignore the first column (i.e. start from Cset.value(1))

                  "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

                  1 Reply Last reply
                  1
                  • gfxxG gfxx

                    @Tschikkn Iread a pos where these problem was solved change "id_val = :id_val) to (:id_val) ......

                    this is my table....

                    CREATE TABLE val_chan (
                        "id_val" INTEGER NOT NULL,
                        "a" INTEGER,
                        "b" INTEGER,
                        "c" INTEGER,
                        "a1" INTEGER,
                        "b1" INTEGER,
                        "c1" INTEGER,
                        "d" INTEGER,
                        "canny" INTEGER,
                        "e" INTEGER,
                        "f" INTEGER,
                        "g" INTEGER,
                        "h" INTEGER,
                        "nomepgr" TEXT,
                        "m" INTEGER,
                        "n" INTEGER,
                        "o" INTEGER,
                        "p" INTEGER,
                        "q" INTEGER,
                        "gap" INTEGER,
                        "ip" TEXT,
                        "port" TEXT,
                        "mask" TEXT,
                        "gain" INTEGER,
                        "exposure_abs" INTEGER,
                        "exposure" INTEGER,
                        "brightness" INTEGER,
                        "contrast" INTEGER,
                        "hue" INTEGER,
                        "saturation" INTEGER,
                        "white" INTEGER,
                        "framerate" INTEGER,
                        "autowhite" INTEGER,
                        "autogain" INTEGER,
                        "autoexposure" INTEGER,
                        "matrixptax" INTEGER,
                        "matrixptay" INTEGER,
                        "martixptbx" INTEGER,
                        "matrixptby" INTEGER,
                        "matrixptcx" INTEGER,
                        "matrixptcy" INTEGER,
                        "matrixptdx" INTEGER,
                        "matrixptdy" INTEGER,
                        "rectax" INTEGER,
                        "rectay" INTEGER,
                        "rectbx" INTEGER,
                        "rectby" INTEGER,
                        "line" INTEGER,
                        "offsetxm" REAL,
                        "offsetym" REAL
                    

                    Regards
                    giorgio

                    T Offline
                    T Offline
                    Tschikkn
                    wrote on last edited by
                    #9

                    @gfxx matrixptbx is not martixptbx INTEGER,

                    gfxxG 1 Reply Last reply
                    3
                    • T Tschikkn

                      @gfxx matrixptbx is not martixptbx INTEGER,

                      gfxxG Offline
                      gfxxG Offline
                      gfxx
                      wrote on last edited by
                      #10

                      @Tschikkn Tanks a lot ..... yesterday night these solve my problem .... is not the first time I lose a lot of time for these things .... now is that I create a control input parser in bash ... input1 the list of column names, input2 my sql statement code snip .txt format, output a single column name + number of times it has been inserted ..... in this case I would find the "martixptbx" column with no. 1 while be nr. 2 ..... many thanks I owe you a beer ...;))

                      regards
                      Giorgio

                      bkt

                      T 1 Reply Last reply
                      0
                      • gfxxG gfxx

                        @Tschikkn Tanks a lot ..... yesterday night these solve my problem .... is not the first time I lose a lot of time for these things .... now is that I create a control input parser in bash ... input1 the list of column names, input2 my sql statement code snip .txt format, output a single column name + number of times it has been inserted ..... in this case I would find the "martixptbx" column with no. 1 while be nr. 2 ..... many thanks I owe you a beer ...;))

                        regards
                        Giorgio

                        T Offline
                        T Offline
                        Tschikkn
                        wrote on last edited by
                        #11

                        @gfxx Most of the time I'm having similiar problems while trying to code. It is hard to have a look "from outside" so you're welcome ;)

                        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