Search code examples
sql-server-2005office-2007

Error when retrieving office 2007 files from sql server 2005 blob


I have a simple document storage database that allows people to upload various types of documents and then do a full-text search on them.

It works just fine for all documents except office 2007 documents. My retrevial code uses content type "application/octet-stream", the server has the MIMETypes registered as does my computer. I can open the file just fine on my system, but uploading it and then redownloading it gives an error:

"This error can be caused by some of the following conditions:

  • Your hard drive or floppy drive has a corrupt section (damaged track or sector).
  • A temporary operating system or network failure has occurred.
  • Your network is unavailable, slow, or is corrupting data packets (failure of a router, network card, or noise on the network transmission line).

If the network is experiencing problems, it is usually a temporary condition and if you wait a short period of time and try again, you can usually save the file. If the problem persists, consult your network administrator"


Solution

  • It would be tough for others to have debugged this, but when I created a byteStream, I used length, instead of length - 1. For some reason in almost all documents this is no problem, but office 2007 threw a fit.