TindellT01 wrote in dk.edb.internet.webdesign.serverside.asp:
> I am trying to display an image(jpg) from an oracle blob field.
> When I use the code below, I get what looks like a broken link. I can retrieve
> the image in the blob field using VB6 or Crystal Reports but not with ASP.
> Any suggestions?
>
> FILE: SHOWIMG.ASP
> <%@ LANGUAGE="VBSCRIPT" %>
> <%
> ' Clear out the existing HTTP header information
> Response.Expires = 0
> Response.Buffer = TRUE
> Response.Clear
>
> ' Change the HTTP header to reflect that an image is being passed.
> Response.ContentType = "image/jpeg"
>
> Set cn = Server.CreateObject("ADODB.Connection")
> ' The following open line assumes you have set up a System DataSource
> ' by the name of myDSN.
> cn.Open "DSN=myDSN;UID=sa;PWD=;DATABASE=pubs"
> Set rs = cn.Execute("SELECT logo FROM pub_info WHERE pub_id='0736'")
> Response.BinaryWrite rs("logo")
> Response.End
> %>
>
>
I found this piece of code on
www.activeserverpages.dk on how to extract code from
an SQL database. I think it'll work on an Oracle DB too if you just change the DSN
string.
<%
Dim Image
Set myConn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.RecordSet")
strDSN = "DRIVER={Microsoft Access Driver
(*.mdb)};DBQ="&Server.MapPath("/aspdigital/db/demo.mdb")
myConn.Open strDSN
strSQL = "SELECT ImageData FROM Images WHERE ImageID = 1"
rs.Open strSQL, myConn, 1
If Not rs.EOF Then
strImage = rs("ImageData").GetChunk(1024000)
Response.ContentType = "image/gif"
Response.BinaryWrite strImage
Else
Response.Write "Picture not found in database"
End If
rs.Close
myConn.Close
Set rs = Nothing
Set myConn = Nothing
Response.End
%>
--
Vil du lære at kode HTML, XHTML, CSS, SSI eller ASP ???
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! =>
http://www.html.dk/tutorials