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
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();

Naresh Babu GopavaramPosted Aug 5, 2011, 8:25 AM
Naresh Babu GopavaramPosted Aug 5, 2011, 8:20 AM
Satish BhatPosted Aug 5, 2011, 8:11 AM
As per my understanding, OfferPdf is the property of offer object? Are you using strongly typed dataset or custom business object. In both the cases what is the type of the OfferPdf.
Naresh Babu GopavaramPosted Aug 5, 2011, 8:05 AM
Naresh Babu GopavaramPosted Aug 5, 2011, 8:01 AM
I am using the following code for retriving the file,
Satish BhatPosted Aug 5, 2011, 6:24 AM
May be there's issue while saving the file in database and it might got corrupted.
2] What is the datatype and size of the field in SQL server database? is it varbinary(MAX)?
3] try using FileStream
// SAVE TO DATABASE
}
Naresh Babu GopavaramPosted Aug 5, 2011, 5:29 AM