[Qt-interest] Proper way to update a BLOB field

Andre Somers andre at familiesomers.nl
Wed Apr 14 15:33:13 CEST 2010


On 14-4-2010 14:47, David Boosalis wrote:
> Using Qt SQlite I can add a record containing a blob, but unable to 
> update a BLOB using the striing way.  I've tried something like this.
>
> QString str = "UPDATE MyTable SET x='" + QString::number(myClass->x) +
>     "', y='" + QString::number(myClass->y) +
>      ", headerState" + myClass->byteArray +
>       " WHERE id='" + QString::number(myClass->id));
>
> All the fields get updated except for headState.
>
> Perhaps I need to use place holders but I don't know how to do this
>
> Any ideas appreciated.
>
> -David
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>    

Yes, placeholders are a good way to go here. Learn about them, they are 
not that complicated.
Also, I am wondering what string it is that you are building up here as 
your SQL. If myClass->bytearray is what I think it is (a QByteArray), 
then I am supprised the SQL works at all.
Last, you could try to construct your SQL using 
QSqlDriver::sqlStatement. Unfortunately, it is all but undocumented, but 
it should be able to construct a valid SQL statement for you.

André


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100414/5a692020/attachment.html 


More information about the Qt-interest-old mailing list