Solved

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

Posted on 2008-06-12
2
855 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 …
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now