损坏的文件 Microsoft Office 2007 ASP.NET 1.1 和 SQL Server
我正在开发一个 ASP.NET 1.1 网站,该网站将文件存储在数据库中。自 2001 年以来,该网站一直运行良好,上传和下载任何类型的文档都没有问题。
但是,最近客户注意到所有 Microsoft Office 2007 文档 DOCX
、XLSX
等当任何用户尝试下载它们时,它们都会被损坏。
我注意到 SQL Server 在 DocumentContent
(图像列)中添加了一个额外的字节。在上传文档之前,内容和长度都很好。然而,在它们被存储之后,SQL Server 会添加一个额外的字节......为什么??????
互联网上的许多人提供了如何下载该文件的解决方案,这很棒并且对我有用。
我正在寻找这个问题的答案...为什么 SQL SERVER 向图像列添加额外的字节?
它是 Asp.NET 1.1 和 SQL 2000,但我们刚刚将其移至 2008 年,但仍然存在相同的问题。
I am working on an ASP.NET 1.1 website that stores files in the database. The website has been working great with no problems uploading and downloading any type of documents since 2001.
However, recently the customer noticed that all Microsoft Office 2007 documents DOCX
, XLSX
, ect are corrupted when any user try to download them.
What I have noticed is that SQL Server adds an extra byte to the DocumentContent
(image column). Before uploading the document the content and length are fine. However, after they get stored, SQL Server adds an EXTRA Byte.... WHY?????
Many people on the internet provided a solution on how to download the file, which is great and it worked for me.
I am looking for an answer to this question... WHY DOES SQL SERVER ADD AN EXTRA BYTE TO THE IMAGE COLUMN?
It is an Asp.NET 1.1 and SQL 2000 but we just moved it to 2008 and we still have the same problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不能 100% 确定您的问题是否与我遇到的问题相同,但就我而言,我发现问题实际上是在写作部分,而不是在阅读部分。例如,我原来的编写代码是这样的:
当我将第一行更改为以下内容时:
读取错误消失了。我只是忘记了,当您在没有指定下限的情况下确定尺寸时,VB 实际上默认分配 N+1 个字节(O 到 N)。请参阅此处描述的类似情况:上传的 Docx 文件已损坏。希望有帮助。
I am not 100% sure if your problem was the same as what I have had but in my case, I found that the problem was actually in the writing part, not in the reading part. For example, my original writing code was like this:
When I changed the first line as the following :
the reading error disappeared. I just forgot that VB actually allocates N+1 bytes (O to N) by default when you dimension it without specifying the lower bound. See similar situation described here: Uploaded Docx Files are getting corrupted . Hope that helps.