Displaying Img from Access using BinaryWrite

N

Nathan Henderson

Hi,
Becoming quite frustrated with this.
I have a commercial database written in access and I'm trying to display
some images, jpegs, stored in the DB on web page.
My code is as follows:

Response.ContentType = "image/jpeg"

sql = "SELECT PartImage FROM Parts WHERE ShortID='AAPTM01'"
Set rs = AMConn.execute(sql)
If not rs.eof Then
PicSize = rs("PartImage").ActualSize
if PicSize > 0 then
Response.BinaryWrite
rs("PartImage").GetChunk(rs("PartImage").ActualSize)
end if
End If
set rs = nothing


All i get on the page is the image not found icon with the red cross in IE.
What could possibly be going on?

Any suggestions would be appreciated.
 
R

Rob

I think you'll find the following will work:-

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

sql = "SELECT PartImage FROM Parts WHERE ShortID='AAPTM01'"
Set rs = AMConn.execute(sql)
If not rs.eof Then
Response.BinaryWrite rs("Partimage")
set rs = nothing
Response.End
else
set rs = nothing
end if
%>
--
Rob Collyer
_______________________________
www.webforumz.com
Free webdesign and development help,
tips, and website critique.
 
N

Nathan Henderson

Sorry, didn't work, same prob,

I can't even seem to get it working on a db i have set up myself.
I gather this is the way to insert them: right click on field> insert
object> create from file> select the jpeg. Seems pretty sraight forward but
i cannot for the life of me figure out whats wrong.

any other suggestions??
I really need to get this going.
 
B

Bã§TãRÐ

This help you at all?


Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.Open datasourcename

' Create Recordset
Set Disp_img = Server.CreateObject("ADODB.Recordset")
Disp_img.Open "SELECT file_image_blob FROM table_name WHERE
F_ID =" & Request("F_ID"), DataConn, 2, 3

If Not Disp_img.EOF Then
Response.ContentType = "image/jpeg"
Response.BinaryWrite Disp_img("file_image_blob")
End If

Disp_img.Close
Set Disp_img = Nothing

DataConn.Close
Set DataConn = Nothing



Let me know.

- Bastard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,121
Latest member
LowellMcGu
Top