Load Image From Db Problem
-
wrote on 25 Aug 2016, 16:49 last edited by VRonin
yep, you should check QSqlQuery::bindValue
sql.prepare("UPDATE Patient_File SET SskeletonPic= :skp WHERE SmeliCode= :smc"); sql.bindValue(":skp",inByteArraye); sql.bindValue(":smc",seMcode); sql.exec();
this also prevents SQL Injection. You should never really use unescaped input directly to build the query string
-
yep, you should check QSqlQuery::bindValue
sql.prepare("UPDATE Patient_File SET SskeletonPic= :skp WHERE SmeliCode= :smc"); sql.bindValue(":skp",inByteArraye); sql.bindValue(":smc",seMcode); sql.exec();
this also prevents SQL Injection. You should never really use unescaped input directly to build the query string
-
wrote on 25 Aug 2016, 16:58 last edited by VRonin
make the field varbinary(max), save it that way and the code you have will work, no changes needed on the load part
image in SQL server is a fixed length string. it has nothing to do with images
-
wrote on 21 Jun 2017, 14:48 last edited by
Hi!
The same problem, you could solve?
Thanks -
Summary of the above:
- in the database use the type
VABBINARY
notIMAGE
- use QSqlQuery::bindValue instead of string concatenation to build your query
wrote on 22 Jun 2017, 06:00 last edited by@VRonin Thank you for reply, but my problem is the load image from database, please see my another question:
QT 5.8 image from database error - in the database use the type