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. QT bindValue(class QSqlQuery) + Mysql problem
Forum Updated to NodeBB v4.3 + New Features

QT bindValue(class QSqlQuery) + Mysql problem

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 7.3k 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.
  • G Offline
    G Offline
    galaksi101yahoo.co.id
    wrote on last edited by
    #1

    Hi friends, could you lying your hand on my problem:

    I am trying to work with insert data through the qt query by using lineEdit and bind it. But Tt works on my pc, database connection also run,and the data also inserted after button clicked (the data take out from lineEdit by binding).

    But the problem starting up appear when I transfers my source code and database to the my laptop. the database connection is working properly but sad to say that the mysql can not get the data, there is no error and everything is ok, the only problem is the data which inserted through lineEdit can not execute to the mysql table.

    both of my machine is 64 bit window 7 os. my pc is pro and my laptop is home(is it problem?)
    and if i use to a normal query like direct insert without binding:

    QSqlQuery query;
    query.exec("INSERT INTO employee (id, name, salary) "
    "VALUES (234234, 'hery', 300)");

    it works and the data will be inserted to the mysql table. but if i used to binding process by using lineEdit the data is fail to execute:

    QSqlQuery query;
    query.prepare("INSERT INTO employee (id, name, salary) "
    "VALUES (:id, :name, :salary)");
    query.bindValue(":id", line1->text().toInt());
    query.bindValue(":name", line2->text());
    query.bindValue(":salary",line3->text().toInt());
    query.exec();

    and THE WEIRD IS ON MY ANOTHER COMPUTER IS WORK..ONLY AT MY LAPTOP GOT PROBLEM. mysql version is same,my qt library version also same, the different only my windows 7 version. pro and home.

    could you help me friends what the hell about this?thanks so much

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      If code which you given is the your real code then change exec() like below:
      @if(!query.exec())
      {
      qDebug()<<"Last error:"<<query.lastError();
      }@
      if not, show us part of your real code.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        galaksi101yahoo.co.id
        wrote on last edited by
        #3

        Nice code trapping Mr Qxoz: and here is the result, so strange:

        last Error QSqlError(2036, "QMYSQL3: Unable to bind value", "Using unsupported buffer type: -842150451 (parameter: 1)")

        there is something weird about: "Using unsupported buffer type"
        is it because of there is 2 sql installed on my machine? but another mysql is disabled already.

        again sir your help is on demand..I don't have any idea about this kind of error

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on last edited by
          #4

          Try copy libmysql.dll to the same dir where your binary(*.exe).

          1 Reply Last reply
          0
          • G Offline
            G Offline
            galaksi101yahoo.co.id
            wrote on last edited by
            #5

            I allocated the libmysql.dll to my binary aplication. but still can not, the most disturbing my feeling is why when I run the programon my computer, that program run smoothly and the data can be fetched/inserted properly otherwise in my laptop got problem such what I explained

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              qxoz
              wrote on last edited by
              #6

              I cant say you why exactly but when i had this kind of problem, i just rebuild QMySql plugin. Other people says that it can happend because of incompatible libraries. Try rebuild plugins on your laptop.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                AntonyEnergy
                wrote on last edited by
                #7

                I had similar problem. I develop application using SQLite and then move to MySQL. My bug was that I was using constructor
                @
                QSqlQuery query("SELECT .... ID=:id")
                @
                instead of
                @
                query.prepare("SELECT .... ID=:id")
                @
                On QSLite contructor warks ok, but not in MySQL.

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  rtomek
                  wrote on last edited by
                  #8

                  Sounds like you've got conflicting versions of MySQL. Make sure you're using the right dll on the non-working system.

                  See here: http://lists.mysql.com/mysql/215915

                  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