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:

Qt Code:
  1. QSqlQuery query;
  2. QByteArray bArray;
  3. QBuffer buffer(&bArray);
  4. buffer.open(QIODevice::WriteOnly);
  5. QDataStream out(&buffer);
  6. out << _pixmap.toImage();
  7. buffer.close();
  8. query.prepare("insert into memos(snap,snap_time) values (:snap, :time)");
  9. query.bindValue(":snap",bArray->constData());
  10. query.bindValue(":time",_time.toString("yyyy-MM-dd hh:mm:ss"));
  11. if(!query.exec())
  12. QMessageBox::warning(0,"Error inserting snap","SNAP");
To copy to clipboard, switch view to plain text mode 

Thank you for help