Microsoft Knowledge Base Email Alertz

(194799) - This article explains how to insert and retrieve RAW or LONG RAW data from an Oracle database for use in an Active Server Pages (ASP) page.

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 194799 - Last Review: July 1, 2004 - Revision: 3.2

How To Retrieve RAW/LONG RAW Data from Oracle for ASP Page

This article was previously published under Q194799

SUMMARY

This article explains how to insert and retrieve RAW or LONG RAW data from an Oracle database for use in an Active Server Pages (ASP) page.

MORE INFORMATION

  1. To insert images into an Oracle table, see the following article in the Microsoft Knowledge Base:
    185958  (http://kbalertz.com/Feedback.aspx?kbNumber=185958/EN-US/ ) How To Use ADO GetChunk/AppendChunk with Oracle for BLOB Data
    NOTE: We do not recommend using Microsoft Access to insert images into Oracle. Microsoft Access adds an OLE wrapper around the object that prevents the object from being extracted and interpreted correctly by ASP.
  2. To query and display the image, use the following code:
          <%@ LANGUAGE="VBSCRIPT" %>
    
          <%
          'Clear existing HTTP header information.
          Response.Expires = 0
          Response.Buffer = TRUE
          Response.Clear
    
          'Set the HTTP header to an image type, if you want to display
          'a jpg you need to use the "image/jpeg" content type.
          Response.ContentType = "image/gif"
    
          Dim strTemp
    
          Set oConn = Server.CreateObject("ADODB.Connection")
    
         'You need to change this line to reflect your DSN, UID
         'and PWD.
          oConn.Open "DSN=Ovteam;UID=userid;PWD=password;"
    
         'Change this line to use your table that contains a raw or
         'long raw field.  In this case, ID is the primary key of the
         'IMAGE table and IMG is the RAW or LONG RAW data column.
          sSQL = "Select ID, IMG from IMAGE where ID = 1"
    
          Set oRS = Server.CreateObject("ADODB.Recordset")
          oRS.Source = sSQL
          oRS.ActiveConnection = oConn
    
         'The cursor type does not seem to matter.  A keyset cursor was used
         'with success for this article; however, you will not be able to
         'scroll with it because the content type of this page is set for
         '"image/gif".
    
          oRS.Open
    
          strtemp = oRS("IMG")
          Response.BinaryWrite(strTemp)
          Response.End
    
          oRS.Close
          Set oRS = nothing
          oConn.Close
          Set oConn = nothing
       %>
    					
NOTE: Because you are changing the content type of this page, you can display only one image. In order to incorporate this into a page with text, you need to do a server side include of this .asp page to get the picture into another page.

REFERENCES

For additional information, please see the following article in the Microsoft Knowledge Base:
192743  (http://kbalertz.com/Feedback.aspx?kbNumber=192743/EN-US/ ) How To Use ADO GetChunk/AppendChunk with Oracle for TEXT Data

APPLIES TO
  • Microsoft Open Database Connectivity 2.5
  • Microsoft ActiveX Data Objects 2.0
  • Microsoft ActiveX Data Objects 2.1
  • Microsoft ActiveX Data Objects 2.1 Service Pack 2
  • Microsoft ActiveX Data Objects 2.5
  • Microsoft ActiveX Data Objects 2.6
  • Microsoft ActiveX Data Objects 2.7
  • Microsoft Active Server Pages 4.0
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.7
Keywords: 
kbcode kbhowto kboracle kbprovider KB194799
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate