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. Problem with Query - QODBC, Informix
Forum Updated to NodeBB v4.3 + New Features

Problem with Query - QODBC, Informix

Scheduled Pinned Locked Moved Solved General and Desktop
qodbcinformixquery
15 Posts 4 Posters 6.7k 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.
  • mrjjM mrjj

    hi and welcome
    You english is very fine.

    Can you maybe post the part where u create this table/db.
    As its hard to say anything without knowing the underlying fields.

    M Offline
    M Offline
    Mich.Q
    wrote on last edited by Mich.Q
    #3

    Yes of course, I hope If paste link from PasteBin is fine.
    pacjenci_window.h:
    http://pastebin.com/BVs0WrRd
    pacjenci_window.cpp:
    http://pastebin.com/AH2G3DhC

    @edit other's action's button's and table action not work corretly too :) but step by step for solve all problem's :)
    @old pastebin, sorry, now changed to the newest code.

    1 Reply Last reply
    0
    • O Offline
      O Offline
      ObiWan
      wrote on last edited by
      #4

      Maybe the following helps:

      uQuery.prepare("INSERT INTO pacjent(nr_ubezpieczenia, imie_pacjenta, nazwisko_pacjenta, adres_pacjenta, telefon_pacjenta) VALUES(?, ?, ?, ?, ?)");
      uQuery.bindValue(0 ,ui->nr_ub->text());
      uQuery.bindValue(1 ,ui->imie->text());
      uQuery.bindValue(2 ,ui->nazwisko->text());
      uQuery.bindValue(3 ,ui->adres->text());
      uQuery.bindValue(4 ,ui->nr_tel->text());
      
      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mich.Q
        wrote on last edited by Mich.Q
        #5

        @ObiWan
        No, still not working :(

        @edit I changed some options in IBM Informix ODBC driver setup, now it looks like:
        https://img42.com/AGfcv
        And now I'm getting this error:
        QODBCResult::exec: Unable to execute statement: "[Informix][Informix ODBC Driver][Informix]CURSOR not on SELECT statement."

        1 Reply Last reply
        0
        • O Offline
          O Offline
          ObiWan
          wrote on last edited by
          #6

          Have you noticed the end of th query:

          INSERT INTO ... VALUES(?, ?, ?, ?, ?)
          
          

          I aks, because there is no line break and it's not visible.

          M 1 Reply Last reply
          0
          • O ObiWan

            Have you noticed the end of th query:

            INSERT INTO ... VALUES(?, ?, ?, ?, ?)
            
            

            I aks, because there is no line break and it's not visible.

            M Offline
            M Offline
            Mich.Q
            wrote on last edited by Mich.Q
            #7

            @ObiWan
            Yes, I just copied your code to mine.
            void pacjenci_window::on_dodaj_clicked()
            {
            QSqlQuery uQuery = QSqlQuery(db);
            uQuery.prepare("INSERT INTO pacjent(nr_ubezpieczenia, imie_pacjenta, nazwisko_pacjenta, adres_pacjenta, telefon_pacjenta) VALUES(?, ?, ?, ?, ?)");
            uQuery.bindValue(0 ,ui->nr_ub->text());
            uQuery.bindValue(1 ,ui->imie->text());
            uQuery.bindValue(2 ,ui->nazwisko->text());
            uQuery.bindValue(3 ,ui->adres->text());
            uQuery.bindValue(4 ,ui->nr_tel->text());
            uQuery.exec();
            sQuery.prepare("SELECT * FROM pacjent");
            if(!sQuery.exec()){
            qDebug() << uQuery.lastError().text() << " DODAJ BUTTON select";
            }
            sQuery.last();
            FillForm();
            }
            @added qDebug to uQuery too, new error:
            QODBCResult::exec: Unable to execute statement: "[Informix][Informix ODBC Driver][Informix]CURSOR not on SELECT statement."
            "[Informix][Informix ODBC Driver][Informix]CURSOR not on SELECT statement. QODBC3: Unable to execute statement" DODAJ BUTTON insert

            1 Reply Last reply
            0
            • O Offline
              O Offline
              ObiWan
              wrote on last edited by
              #8

              Qt docu says:
              QString stores a string of 16-bit QChars, where each QChar corresponds one Unicode 4.0 character.

              Informix is old and I suppose cannot handle Unicode.
              Try toStdString() or toLocal8Bit() to bind values.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Mich.Q
                wrote on last edited by Mich.Q
                #9

                toStdString() - error:
                C:\Users\michu\Documents\przychodnia_projekt\pacjenci_window.cpp:60: błąd: no matching function for call to 'QSqlQuery::bindValue(int, std::string)'
                uQuery.bindValue(1 ,ui->imie->text().toStdString());
                ^
                Trying to add additional variables with toStdString() and then add them to bindvalue by name but dont work too.

                toLocal8bit() - the same error as on begin:
                QODBCResult::exec: Unable to execute statement: "[Informix][Informix ODBC Driver][Informix]CURSOR not on SELECT statement."
                "[Informix][Informix ODBC Driver][Informix]CURSOR not on SELECT statement. QODBC3: Unable to execute statement" DODAJ BUTTON insert

                @edit:
                trying with toUtf8() - same error like above.
                with toWCharArray() - same error like toStdString()

                @edit
                for toStdString() & toUtf8 I added data() but now error is the same like for others...

                uQuery.bindValue(1 ,ui->imie->text().toUtf8().data());

                error:
                QODBCResult::exec: Unable to execute statement: "[Informix][Informix ODBC Driver][Informix]CURSOR not on SELECT statement."
                "[Informix][Informix ODBC Driver][Informix]CURSOR not on SELECT statement. QODBC3: Unable to execute statement" DODAJ BUTTON insert

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Mich.Q
                  wrote on last edited by
                  #10

                  Yes! I found solution. Its simply uncheck option Insert Coursor in ODBC IBM driver config...
                  Like on picture:
                  https://img42.com/r4DZU
                  Thanks guys for support.

                  1 Reply Last reply
                  1
                  • E Offline
                    E Offline
                    erick joshua
                    wrote on last edited by
                    #11

                    hi,@Mich-Q ,i'm new about qt and informix, i need informix driver,can you sent it to me.if it is win32,it is better,can you?my english is terrible-.-。thank you.

                    mrjjM 1 Reply Last reply
                    0
                    • E erick joshua

                      hi,@Mich-Q ,i'm new about qt and informix, i need informix driver,can you sent it to me.if it is win32,it is better,can you?my english is terrible-.-。thank you.

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

                      @erick-joshua

                      Hi and welcome to the forums
                      you can use ODBC for connecting Qt to informix server.
                      As far as i know there is no native Qt driver for informix.

                      https://www.ibm.com/developerworks/data/library/techarticle/dm-1108odbcdrivermanager/index.html

                      Sorry I dont its download link.

                      E 1 Reply Last reply
                      0
                      • mrjjM mrjj

                        @erick-joshua

                        Hi and welcome to the forums
                        you can use ODBC for connecting Qt to informix server.
                        As far as i know there is no native Qt driver for informix.

                        https://www.ibm.com/developerworks/data/library/techarticle/dm-1108odbcdrivermanager/index.html

                        Sorry I dont its download link.

                        E Offline
                        E Offline
                        erick joshua
                        wrote on last edited by
                        #13

                        @mrjj hi,i know there is no native qt driver for informix.when i saw this topic ,i find https://img42.com/r4DZU,there is a dialog which title is "ibm informix odbc driver setup", i think you have the informix odbc driver...
                        i guess you dont have informix odbc driver,is that right?

                        mrjjM 1 Reply Last reply
                        0
                        • E erick joshua

                          @mrjj hi,i know there is no native qt driver for informix.when i saw this topic ,i find https://img42.com/r4DZU,there is a dialog which title is "ibm informix odbc driver setup", i think you have the informix odbc driver...
                          i guess you dont have informix odbc driver,is that right?

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

                          @erick-joshua
                          Yes, Qt do not come with ODBC drivers. They are supplied by the vendors or microsoft.
                          Oddly i cannot find a download link at IBM.
                          Even other pages mention it
                          http://www.ciscounitytools.com/Applications/CxN/InformixODBC/InformixODBC.html
                          This seems to be the SDK
                          http://www.ciscounitytools.com/Applications/CxN/InformixODBC/clientsdk.4.10.TC7DE.WIN.zip
                          but i have no idea what version of the actual server it works with etc.

                          E 1 Reply Last reply
                          1
                          • mrjjM mrjj

                            @erick-joshua
                            Yes, Qt do not come with ODBC drivers. They are supplied by the vendors or microsoft.
                            Oddly i cannot find a download link at IBM.
                            Even other pages mention it
                            http://www.ciscounitytools.com/Applications/CxN/InformixODBC/InformixODBC.html
                            This seems to be the SDK
                            http://www.ciscounitytools.com/Applications/CxN/InformixODBC/clientsdk.4.10.TC7DE.WIN.zip
                            but i have no idea what version of the actual server it works with etc.

                            E Offline
                            E Offline
                            erick joshua
                            wrote on last edited by
                            #15

                            @mrjj thank you still

                            1 Reply Last reply
                            1

                            • Login

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