如何在SQL Server 2008中存储图像blob数据?

Dee*_*dhy 2 sql-server coldfusion sql-server-2008 coldfusion-10

我需要将图像blob数据存储在表中.我知道在数据库表中以blob格式存储图像不是最佳做法.但这样做是客户的要求.我正在使用ColdFusion 10和SQL Server 2008.我已使用此代码段在SQL Server中插入图像blob数据.

<cfimage action="read" name="imdata" source="C:\inetpub\wwwroot\a.jpg" >

<cfquery datasource="localdsn">
  INSERT INTO imtbl(image)
  VALUES #imageGetBlob(imdata)#
</cfquery>
Run Code Online (Sandbox Code Playgroud)

但这是在抛出错误

ByteArray objects cannot be converted to strings.

我也试过使用#toString(imageGetBlob(imdata))#仍然没有成功.

我已经通过https://forums.adobe.com/thread/60629但是找不到任何解决方案.

Dee*_*dhy 5

最后我解决了这个问题.我做的两件事是,

  1. 我已为数据源启用了BLOB设置.

  2. 我终于使用了这个查询

<cfquery datasource="localdsn"> INSERT INTO imtbl(image) VALUES ( <cfqueryparam cfsqltype="cf_sql_blob" value="#fileReadBinary('C:\inetpub\wwwroot\a.jpg')#"> ) </cfquery>