Qt MYSQL Prepared Statement Error Using Undefined Buffer <number>
-
wrote on 28 Oct 2014, 09:41 last edited by
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:- I get some data from network
- I search for that data in the database
- 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?
-
wrote on 28 Oct 2014, 10:32 last edited by
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. -
wrote on 28 Oct 2014, 10:36 last edited by
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
-
wrote on 28 Oct 2014, 10:50 last edited by
Could you post the line with the prepared statement and the bindvalue line?
-
wrote on 29 Oct 2014, 04:05 last edited by
@
//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.
-
wrote on 29 Oct 2014, 09:38 last edited by
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");
@ -
wrote on 29 Oct 2014, 09:59 last edited by
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 --- Uninstalled my MySQL5.0 ans intalled MySQL6.0.
- Installed MySQL6.0.
- Recompiled the Qt-MySQL drivers for MySQL6.0.
- 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 ?
-
wrote on 29 Oct 2014, 10:54 last edited by
Your tests point to a problem with compatibility - but I haven't heard about it yet...
1/8