QT bindValue(class QSqlQuery) + Mysql problem

  • 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());

    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

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

  • 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

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

  • 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

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

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

  • 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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.