Results 1 to 7 of 7

Thread: Inserting PNG into Database - Escaping String

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Inserting PNG into Database - Escaping String

    Hi all,

    I am trying to insert a PNG image into a mysql database using Qt.
    I am facing the problem to escape special characters into image and
    I cannot find any function in Qt related to this.

    I am attaching the piece of my code for this.

    Qt Code:
    1. QBuffer buffer(&ba);
    2. buffer.open(QIODevice::WriteOnly);
    3. image->save(&buffer, "PNG"); //image is a QImage
    4.  
    5. QString sql = QString( "INSERT INTO myTable ( blob ) VALUES ( %1 )").arg( ba.data() )
    To copy to clipboard, switch view to plain text mode 

    and when exec() this sql query, I get an error. Most probably I need to escape `ba.data()'
    plz help
    Last edited by high_flyer; 16th March 2011 at 13:31. Reason: code tags

Similar Threads

  1. Escaping %1 with QString::arg()
    By marcvanriet in forum Newbie
    Replies: 2
    Last Post: 20th January 2011, 01:38
  2. Replies: 2
    Last Post: 13th February 2010, 18:33
  3. inserting content in database
    By codeman in forum Qt Programming
    Replies: 2
    Last Post: 3rd June 2009, 16:47
  4. Problem while inserting the data into database
    By sudheer168 in forum Qt Programming
    Replies: 2
    Last Post: 13th December 2008, 12:22
  5. inserting string > 127 characters to MS Access
    By jh in forum Qt Programming
    Replies: 0
    Last Post: 12th May 2006, 17:11

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.