/ Forside / Teknologi / Udvikling / ASP / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
ASP
#NavnPoint
smorch 9259
Harlekin 1866
molokyle 1040
Steffanst.. 758
gandalf 657
smilly 564
gibson 560
cumano 530
MouseKeep.. 480
10  Random 410
displaying ADO oracle blob field
Fra : TindellT01


Dato : 17-08-01 01:24

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
%>



 
 
Thomas Gottschalk La~ (17-08-2001)
Kommentar
Fra : Thomas Gottschalk La~


Dato : 17-08-01 16:57

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" %>
> <%
&gt; ' Clear out the existing HTTP header information
&gt; Response.Expires = 0
&gt; Response.Buffer = TRUE
&gt; Response.Clear
&gt;
&gt; ' Change the HTTP header to reflect that an image is being passed.
&gt; Response.ContentType = "image/jpeg"
&gt;
&gt; Set cn = Server.CreateObject("ADODB.Connection")
&gt; ' The following open line assumes you have set up a System DataSource
&gt; ' by the name of myDSN.
&gt; cn.Open "DSN=myDSN;UID=sa;PWD=;DATABASE=pubs"
&gt; Set rs = cn.Execute("SELECT logo FROM pub_info WHERE pub_id='0736'")
&gt; Response.BinaryWrite rs("logo")
&gt; Response.End
&gt; %>
>
>

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

Søg
Reklame
Statistik
Spørgsmål : 177554
Tips : 31968
Nyheder : 719565
Indlæg : 6408857
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste