Solved

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

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

20 Experts available now in Live!

Get 1:1 Help Now