Solved

How to retrieve and display PDF files stored in an Oracle database?

Posted on 2008-06-12
2
861 Views
Last Modified: 2008-06-19
In my ASP.Net 1.1, VB.net application, I have a new requirement to display a list of PDF files
stored in an Oracle database in a datagrid or a ListView control..  The BLOB files are already in the
database.

Can you provide me some guidance on how to retrieve and open a PDF file when the user
clicks on the item in the list control?

The structure of the table housing the PDF files is as follows, if this information is useful:

AF_KEY                     NUMBER(9)
FILENAME            VARCHAR2(25)
FILETYPE             VARCHAR2(3)
FILE_DT                       DATE
DOCUMENT            BLOB
UPDATE_UI_KEY      NUMBER(9)
UPDATE_DT          DATE

Thanks!
0
Comment
Question by:JeffDrummond
  • 2
2 Comments
 
LVL 37

Expert Comment

by:samtran0331
ID: 21781488
How are you connecting to your Oracle db? OleDb?
0
 
LVL 37

Accepted Solution

by:
samtran0331 earned 500 total points
ID: 21781558
http://support.microsoft.com/kb/326502

The code sample for step 6 and the "Additional Information" section should get you going.
the example is for a MS-SQL database, but it would be the same if you're using OleDb

The steps would be:
1. Fill a dataadapter with your record.
2. Get the datarow and field that contains the BLOB
3. Put the BLOB data into a byte array
4. Use the "Response" object to "write" the file.


Based on the sample code in the link above, yours would look more like:


      'Dim con As New SqlConnection("Server=yileiw2;uid=sqlauth;pwd=sqlauth;database=pubs")
        'Dim da As New SqlDataAdapter("Select * From pub_info", con)
        'Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
      '**Replace the 3 lines above with your connection/objects for Oracle

        Dim ds As New DataSet()

        con.Open()
        da.Fill(ds, "Pub_info")
        Dim myRow As DataRow
        myRow = ds.Tables("Pub_info").Rows(0)

        Dim MyData() As Byte
        MyData = myRow("logo") 'Replace "logo" with the name of your BLOB field
       
        Response.Buffer = True
      Response.AddHeader("Content-Disposition", "attachment;filename=blob.pdf")
        Response.ContentType = "application/pdf"
        Response.BinaryWrite(MyData)
      Response.End

        MyCB = Nothing
        ds = Nothing
        da = Nothing

        con.Close()
        con = Nothing



0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question