Q
Problem solve Get help with specific problems with your technologies, process and projects.

How do I store and view PDF files in a SQL database?

I have some problem with PDF files. How can I store them in a SQL database, and how can I view them on my .NET app screen by clicking on a button?
PDF files can be stored in a SQL database as binary just like any other file, like images or word documents. See http://weblogs.asp.net/cazzu/archive/2003/08/27/25568.aspx for an explanation on how to do that.

As for viewing the PDF in a .NET app, assuming this is a Windows forms app, you will need the Adobe Acrobat Reader installed. Then, you can use the Adobe Control for ActiveX that comes with it. In order to drag and drop it on a Windows form, add it to the toolbox first. Next, you only need to set its src property to the file location and it will show up.

The Adobe ActiveX control provides a LoadFile method for programatically loading a file. Therefore, you will need to pull the PDF out of the database to a temporary file (use Path.GetTempFileName()), and then hand this file name to the control.

Dig Deeper on SQL Server and .NET development

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

TheServerSide.com

SearchCloudApplications

Close