Hi,
I am not so strong in mysql/sql and have this, hopefully, easy question:
How to store/read a .png file in mysql database using Qt.
I have a table containing 2 columns: snap_time,snap; (datetime,blob)
I tried this, but I get an error:
out << _pixmap.toImage();
buffer.close();
query.prepare("insert into memos(snap,snap_time) values (:snap, :time)");
query.bindValue(":snap",bArray->constData());
query.bindValue(":time",_time.toString("yyyy-MM-dd hh:mm:ss"));
if(!query.exec())
QSqlQuery query;
QByteArray bArray;
QBuffer buffer(&bArray);
buffer.open(QIODevice::WriteOnly);
QDataStream out(&buffer);
out << _pixmap.toImage();
buffer.close();
query.prepare("insert into memos(snap,snap_time) values (:snap, :time)");
query.bindValue(":snap",bArray->constData());
query.bindValue(":time",_time.toString("yyyy-MM-dd hh:mm:ss"));
if(!query.exec())
QMessageBox::warning(0,"Error inserting snap","SNAP");
To copy to clipboard, switch view to plain text mode
Thank you for help
Bookmarks