Error while retriving the pdf file from sqlserver DB

Aug 5 2011 1:04 AM
I am saving the pdf file in sqlserver as bytes .When i am trying to retrive and show the file does not shows the content the following error occures

there was an error opening this document the file is damaged and could not be repaired +asp.net

Please any one help me


This is for save 

 byte[] byteArray = System.IO.File.ReadAllBytes(Server.MapPath("Deal//UI//pdfSample.pdf"));

savetoDB();




Retriving
  byte[] document = (byte[])offer.OfferPdf;

                //string strExtenstion = ".pdf";
                string DocName = "pdfSample";
                
                
                Response.ClearContent();                
                Response.AddHeader("content-disposition", "attachment;filename=" + DocName + ".pdf");
                Response.AddHeader("content-length", document.Length.ToString());
                Response.ContentType = "application/pdf";

                //Response.TransmitFile("pdfSample.pdf");

                Response.BinaryWrite(document);

                //Response.Charset = "";
                //Response.Cache.SetCacheability(HttpCacheability.NoCache);
                //Response.Write(document);
                Response.End();




Answers (7)