Solved

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

Posted on 2008-06-12
2
866 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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 …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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