I have a requirement to store image blob data in a table. I know storing an image in blob format within a database table is not best practice. But doing so is a client requirement. I am using ColdFusion 10 and SQL Server 2008. I have used this snippet to insert the image blob data in SQL server .
<cfimage action="read" name="imdata" source="C:\inetpub\wwwroot\a.jpg" >
<cfquery datasource="localdsn">
INSERT INTO imtbl(image)
VALUES #imageGetBlob(imdata)#
</cfquery>
But it is throwing error
ByteArray objects cannot be converted to strings.
I have also tried using #toString(imageGetBlob(imdata))# Still no success.
I have gone through https://forums.adobe.com/thread/60629 But can not find any solution.
<cfqueryparam cfsqltype="cf_sql_blob" value="#imageGetBlob(imdata)#">might help expose whats going on.FileReadBinary()expects a file path. You are passing in an image variable. Get rid of thecfimageand useFileReadBinary("C:\inetpub\wwwroot\a.jpg")inside your cfqueryparam. Also, you obviously need parenthesis in yourVALUES (...)clause.