Results 1 to 7 of 7

Thread: How to update BLOB field in a SQLite database ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    8
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Question How to update BLOB field in a SQLite database ?

    Hello,

    I would like to update a BLOB field in my database with a QByteArray, but it doesn't work. Can you help me ?

    Ma database structure is :

    CREATE TABLE Settings (
    Version nvarchar(10),
    Geometry BLOB
    );

    This database have 1 row :

    INSERT INTO Settings VALUES (
    '0.1',
    ''
    );

    and I would like to update this row with the following source code :

    // connection :
    < database connection code >

    // update :
    QByteArray a_value;
    a_value = saveGeometry(); // saveGeometry return a QByteArray

    QSqlQuery query;
    query.prepare("UPDATE Settings SET Geometry = ':Geometry'");
    query.bindValue(":Geometry", a_value);
    if (query.exec() == false)
    qDebug() << "Error SQL exec()";


    The result is : Error SQL exec()

    Thanks

  2. #2
    Join Date
    Aug 2009
    Location
    Greece
    Posts
    69
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2
    Thanked 14 Times in 14 Posts

    Default Re: How to update BLOB field in a SQLite database ?

    if you pass query.lastError().text() to qDebug() you will get the specific error info

  3. #3
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanked 342 Times in 324 Posts

    Default Re: How to update BLOB field in a SQLite database ?

    Try without the quotes:
    Qt Code:
    1. query.prepare("UPDATE Settings SET Geometry = :Geometry");
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to stampede for this useful post:

    aircraftstories (8th April 2011)

Similar Threads

  1. Help with QT, SQLite, Update Statement
    By chetu1984 in forum Newbie
    Replies: 3
    Last Post: 17th March 2011, 23:24
  2. SQLITE - UPDATE query problem
    By Tomasz in forum Newbie
    Replies: 12
    Last Post: 5th September 2010, 21:27
  3. Replies: 2
    Last Post: 8th April 2010, 17:16
  4. Replies: 2
    Last Post: 17th February 2010, 15:32
  5. Replies: 1
    Last Post: 14th September 2009, 09:48

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
  •  
Qt is a trademark of The Qt Company.