Results 1 to 2 of 2

Thread: MySQL and transaction problem in Qt 4.6.2 on Windows XP SP3

  1. #1
    Join Date
    Mar 2010
    Location
    Bangkok, THAILAND
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation MySQL and transaction problem in Qt 4.6.2 on Windows XP SP3

    Hello. I have a problem about controlling a transaction with MySQL database in Qt 4.6.2 for VS2008 on Windows XP SP3.

    When calling transaction functions including transaction, commit, it'll always return 'true,' but the database isn't updated. Here is my code:

    Qt Code:
    1. // Assume that the connection was open by db.open(), where db is an instance of QSqlDatabase.
    2. QString insertCmd = "INSERT INTO image (img_desc, img_filename) VALUE (?, ?)";
    3.  
    4. QSqlQuery query;
    5.  
    6. db.transaction();
    7. query.prepare(insertCmd);
    8.  
    9. // Assume that imgDesc and imgFileName are QString got from QPlainTextEdit.
    10. query.addBindValue(imgDesc);
    11. query.addBindValue(imgFileName);
    12. query.exec();
    13.  
    14. db.commit();
    To copy to clipboard, switch view to plain text mode 

    But there is no new record in table image in MySQL. So what should I do? Thanks a lot!
    Last edited by nuntawat; 11th March 2010 at 16:52. Reason: changed the title of the thread

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MySQL and transaction problem in Qt 4.6.2 on Windows XP SP3

    Try to look after query.exec() what happened :
    Qt Code:
    1. qDebug() << QSqlDatabase::database().lastError() << endl << query.executedQuery() << endl << query.lastError();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Unable to commit transaction
    By cydside in forum Qt Programming
    Replies: 6
    Last Post: 23rd July 2009, 07:47
  2. SQLite - QSqlDatabase::transaction()
    By whitefurrows in forum Qt Programming
    Replies: 6
    Last Post: 5th May 2009, 16:06
  3. Qt in windows and mysql !!!
    By probine in forum Installation and Deployment
    Replies: 13
    Last Post: 9th December 2006, 07:42
  4. QDatabase::transaction()
    By sunil.thaha in forum Qt Programming
    Replies: 2
    Last Post: 3rd February 2006, 13:15
  5. Qt 4.1 OS on Windows & mysql
    By neeko in forum Installation and Deployment
    Replies: 10
    Last Post: 31st January 2006, 20:22

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.