Qt MYSQL Prepared Statement Error Using Undefined Buffer <number>



  • Dear Friends
    I am building an application with the following environment specs:
    Win 7
    MySQL v5.0
    Qt v 5.0
    MySQL drivers compiled and connection is getting established.

    The problem which i am facing is that when i am creating a prepared statement it doesn't execute properly and gives an error - Using Undefined buffer.
    A brief description about the application that i am making:

    1. I get some data from network
    2. I search for that data in the database
    3. reply to the requesting node after database query.

    The weird thing is that When i rebuild the application and the first run after rebuild goes fine. i.e. one query gets served. for the rest of the queries it throws the error and the query doesn't executes.

    I tried the following:
    1 recompiling the MySQL driver for qt.
    2 re installing the database server.

    It doesn't help.

    Please can anybody help me out. Is there something that I am doing wrong the whole process of the code?



  • Hi,
    do you see only this error message?
    I suggest to run the program in debug mode step by step (near the prepare statement) - with a fresh build and a build which shows the error.



  • I ran in.debug mode also. The exec query fails and the error display says--
    Using unsupported buffer type xxxxx parameter 1. QMYSQL3 UNABLE TO BIND VALUES.

    Where xxxxx is the number that is variable in the error



  • Could you post the line with the prepared statement and the bindvalue line?



  • @
    //some code before this
    dbQuery.prepare("select * from duty_exer_board where board_name = :boardName and board_exercise_flag = :dutyExerFlag");

    dbQuery.bindValue(":boardName",QVariant((char*)&checkBoardName.board_name));
    dbQuery.bindValue(":dutyExerFlag",QVariant((int)checkBoardName.duty_exer_flag));

    if(dbQuery.exec())
    {
    ....//other code
    }

    // a lot of code after this
    @
    The variables are defined as:
    @
    unsigned char board_name[16];
    unsigned char duty_exer_flag;
    @

    I think i am making some mistake but i am unable to make out where to start from.



  • I think, the problem lies in the usage of QVariant.
    How did you define board_name and board_exercise_flag in your database?

    What happens if you assign strings directly to the values:
    @
    dbQuery.bindValue(":boardName","testname");
    dbQuery.bindValue(":dutyExerFlag","1");
    @



  • The variables in Database are:
    boardName is varchar(16)
    board_exercise_flag is int(11).

    Well after 3-4 hours of hit n trial. I figured that the same code is working perfect when I ran it on other system with MySQL6.0.
    Then i --

    1. Uninstalled my MySQL5.0 ans intalled MySQL6.0.
    2. Installed MySQL6.0.
    3. Recompiled the Qt-MySQL drivers for MySQL6.0.
    4. Replaced the old dll files with the newer from v6.0.

    And now its working.

    Can we infer that the Qt v5.0 function bindValue isnt compatiable with MySQL v5.0 :-o ?



  • Your tests point to a problem with compatibility - but I haven't heard about it yet...


Log in to reply
 

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