QMYSQL Transaction support
-
Hello everyone,
I'm starting to learn about Qt and I'm currently creating software that has database interaction.
I'm currently using mysql via xampp on win 8.1.So far I've managed to perform select and insert statements without any problem.
I want to take it a step further by introducing transaction for my insert statements.When I did a check on the db driver for QMYSQL, it returned 'false'.
Question: Is this expected ? is it possible to configure QMYSQL to support transaction?Here is my environment configuration:
- OS: Win 8.1
- QT version: Qt 5.5.0 (MSVC 2013, 32 bit) with MinGw 4.9.2 compiler
- libmysql.dll downloaded from MYSQL C connectors
- xampp version 5.6.12
-
Hi and welcome to devnet,
Where is libmysql.dll located in your computer ?
-
Hello SGaist, thanks for helping out.
I put my libmysql on c:/windows folder.
I tried putting the libmysql in other folder such as mingw lib folder, or project folder, the result is still the same. -
Don't put anything in the windows folder. That's just plain wrong (even though numerous applications does it)
Go to the Run part of the Project panel, update the PATH environment variable and add the path to were that dll is located
-
Hello,
I've moved it but it doesn't solve the problem.
I've used a workaround on this problem by executing transaction through mysql statements.It goes something like this (each '-' line is a query.exec statement) :
-start transaction
-input statement
(check for numrowaffected to see if statement was well executed)
-2nd input statement
(another numaffectedrow check)If both numrowcheck pass
Commit
Else
RollbackIt work fine. Is this a valid solution to go for?
-
Hi @Calvev, I had the same problem of the missing transactions feature. The problem was that I used a new version of libmysql.dll which I got from the MySQL connector package, but the server I was connecting to, was an older MySQL 5.1, so their versions did not match. When I downloaded the old 5.1 server package and extracted the libmysql.dll from there, transactions started to work :o)