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
Related Q&A from Daniel Cazzulino
Here our experts address how to converti a VB Windows application to a VB .NET Web application. Continue Reading