New Members FAQ
Talk to Webmaster Tony John
Asheej T K
How to display a pdf file stored as a image type in DB
27 Nov 2009
I had uploaded a pdf file in my application and saved it as an image datatype in SQL server 2005 table.I had used the code below .I checked the DB it is getting the file in a binary format .My question is how to display the Pdf file stored in DB ?.if i select a pdf file stored in a table it should open in a new window.
public partial class Default2 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e)
Connection1 obj=new Connection1 ();
SqlConnection connection = obj.Connect();
int number = Convert.ToInt32(TextBox1.Text.ToString());
FileUpload img = (FileUpload)FileUpload1;
Byte imgByte = null;
if (img.HasFile && img.PostedFile != null)
HttpPostedFile File =FileUpload1.PostedFile;
imgByte = new Byte[File.ContentLength];
int s= imgByte.GetLength(0);
File.InputStream.Read(imgByte, 0, File.ContentLength);
string sql = "INSERT INTO pdfs1 VALUES('"+imgByte+"',"+number+")";
SqlCommand cmd = new SqlCommand(sql, connection);
// lblResult.Text = "There was an error";
Thanks in advance.
Date: 27/Nov/2009 Rating:
Check this link
You can follow me in twitter : http://www.twitter.com/anuraj
This thread is locked for new responses. Please post your comments and questions as a
If required, refer to the URL of this page in your
Refresh login page after giving userid....and Operator '==' cannot be applied to operands
How to interchange the rows in sql
Return to Discussion Forum
Post New Message
no of click on advertisement in asp.net application
Please Please help.................. tooo urgent
Please tell me .Net interview Questions for 2+ Years Exp
To upload Documents like(doc,pdf,etc) to file system
Last 7 Days
Asheej T K
Awards & Gifts
Articles Rss Feeds
Forum Rss Feeds
Revenue Sharing sites
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2012 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.