Solved

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

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delete HTML table rows 12 30
Check number of row prior to displaying gridview 10 36
vb.net 1 month apart 11 31
vb.net class 3 17
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

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