From: Ali on
I am facing some problem. I uploaded some different files (jpg, bmp, doc,
pdf) into SQL Database using ASP.NET and VB.NET and I tried to download them
again. all files worked properly unless the pdf files. The download goes fine
but when I try to open them, I receive an error declaring that the file is
corrupted and can not be read or even repaired. Their sizes are less than
some of word documents I uploaded and download them later so it has nothing
to do with the size. I don't know why?

If dr.Read Then
Response.ContentType = dr("ContentType").ToString
Response.OutputStream.Write(CType(dr("FileData"), _
Byte()), 0, CInt(dr("FileSize")))
Response.AddHeader("Content-Disposition", _
"attachment;filename=" + dr("FileName").ToString())
End if


I am using Visual Studio .NET 2005 Beta 1

From: Steve C. Orr [MVP, MCSD] on
Be sure to call Response.Clear() before outputting the PDF data, and call
Response.End() right after.

This is to be sure that only the PDF data gets output and no other page
elements which will confuse the PDF viewer.

Also, some versions of Acrobat are more stable than others.

http://SteveOrr.net/articles/EasyUploads.aspx



I hope this helps,

Steve C. Orr,

MCSD, MVP

http://SteveOrr.net



"Ali" <Ali(a)discussions.microsoft.com> wrote in message
news:B1DDC150-85F9-46C1-BA33-AC019A281E4E(a)microsoft.com...
>I am facing some problem. I uploaded some different files (jpg, bmp, doc,
> pdf) into SQL Database using ASP.NET and VB.NET and I tried to download
> them
> again. all files worked properly unless the pdf files. The download goes
> fine
> but when I try to open them, I receive an error declaring that the file is
> corrupted and can not be read or even repaired. Their sizes are less than
> some of word documents I uploaded and download them later so it has
> nothing
> to do with the size. I don't know why?
>
> If dr.Read Then
> Response.ContentType = dr("ContentType").ToString
> Response.OutputStream.Write(CType(dr("FileData"), _
> Byte()), 0, CInt(dr("FileSize")))
> Response.AddHeader("Content-Disposition", _
> "attachment;filename=" + dr("FileName").ToString())
> End if
>
>
> I am using Visual Studio .NET 2005 Beta 1
>