You might want to double check your ColdFusion Database Advanced settings for 
that datasource. Make sure that the Enable CLOB and Enable BLOB items are 
checked. You may also need to increase the Blob Buffer(bytes).

Just suggestions, I don't work with that stuff much.

Steve


-----Original Message-----
From: Christopher Nash [mailto:[email protected]] 
Sent: Friday, August 09, 2013 10:35 AM
To: cf-newbie
Subject: Problems storing PDF as binary in MS SQL 2008 R2


I'm trying to store PDF's (540k) as binary in varbinary(max) field MS SQL 2008 
R2. But for somereason they're getting truncated. I get the error message 
"There was an error opening this document. The file is damaged and could not be 
repaired." (leads me to believe this is a result of truncation)

I've also tested .jpg's (549k) in varbinary(max) or image fields and they're 
truncating too. About 1/3 of the image is stored for varbinary(max) and 2/3 for 
image.

I've referenced many other people's similar soultions, but something is 
tripping me up?

<cffile action="readBinary" file="\\TAFT\Home\COI\Insurance requirment 
Form.pdf" variable="pdffile">
or
<cffile action="readBinary" file="\\TAFT\Home\COI\Lighthouse.jpg" 
variable="pdffile">

<cfquery name="savePDF" datasource="#session.dsnsovranmisc_gar#" dbtype="ODBC">
  UPDATE tblCOI
  Set binCOI = <cfqueryparam cfsqltype="CF_SQL_BLOB" value="#pdffile#">
  WHERE
  intID = 1
</cfquery>

<cfquery name="Contractors" datasource="#session.dsnsovranmisc_gar#" 
dbtype="ODBC">
  SELECT binCOI
  FROM tblCOI
  WHERE
  intID = 1
</cfquery>

<cfcontent type="application/pdf" variable="#Contractors.binCOI#" />

And when I was working with an image field I returned it using the following 
code and could witness the 1/3 (varbinary(max)) and 2/3 (image) of the photo 
then...

<cfset myImg1 = ImageNew(Contractors.imgCOI)>
<cfimage action="WRITETOBROWSER" source="#myImg1#">


Where am I going wrong? My pdf's are all under 1mb so the size shouldn't be a 
problem. Had a cowrker check coldfusion administrator to make sure there wasn't 
any bad defaults for cffile.

Any help/ideas are much appreciated.

Thanks,
-Chris 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:6085
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-newbie/unsubscribe.cfm

Reply via email to