PDA

View Full Version : "How can I display a field that is an image( photo) from a recordset"


Huara
06-10-2003, 05:30 AM
Hello
"How can I display a field that is an image( photo) from a recordset"
I have no problem with text field, they are displaying fine
the data base is in Access:
field name: Type
cod_caritu text
nam_caritu text
pho_caritu Objet OLE

I have used this code:
<% RS.MoveFirst
Do While Not RS.EOF%>
<%=RS("cod_caritu")%>
<Img src="<%=RS("pho_caritu")%>"><BR>
<%
RS.MoveNext
Loop %>


And this, but is the same, there is no display with the 3° field that is a photo:

<% RS.MoveFirst
Do While Not RS.EOF
Response.Write(" Code: " & RS("cod_caritu") & "<BR>")
Response.write(" Name: " & RS("nam_caritu") & "<BR>")
Response.write(" Photo: " & RS("pho_caritu") & "</P>")
RS.MoveNext
Loop %>


3° way
<%@ LANGUAGE="VBScript"%>
<% Response.ContentType = "image/GIF" %>
<BODY>
<% RS.MoveFirst
Do While Not RS.EOF%>
<%=RS("cod_caritu")%>
<% Response.write(RS("pho_caritu")) %> <BR>
<%
RS.MoveNext
Loop %>

so it failed again
maybe I am not using in the right way : <% Response.ContentType = "image/GIF" %>

I'll appreciate if someone could help me, thanks

bmwmpower
06-10-2003, 12:14 PM
this code thsi right

<% RS.MoveFirst
Do While Not RS.EOF%>
<%=RS("cod_caritu")%>
<Img src="<%=RS("pho_caritu")%>"><BR>
<%
RS.MoveNext
Loop %>


but can u tell me how u save the photo in data base may be this is the prblem the way that u saved

fractalvibes
06-10-2003, 10:50 PM
Try using Response.BinaryWrite of the rs(image)

Huara
06-13-2003, 08:49 AM
bmwmpower:
Hello
thanks for your answer, but I have used this code.
you mentioned how I save The photo in data base,
well to be sure I used data base from access too
Neptuno.mdb and Northwind.mdb, (These include a photo field) but I had the same result,
only display the name an next the name appear and square with an x inside.
it is really disappointing.
Huara.



Originally posted by bmwmpower
this code thsi right

<% RS.MoveFirst
Do While Not RS.EOF%>
<%=RS("cod_caritu")%>
<Img src="<%=RS("pho_caritu")%>"><BR>
<%
RS.MoveNext
Loop %>


but can u tell me how u save the photo in data base may be this is the prblem the way that u saved

bmwmpower
06-14-2003, 09:14 AM
yes i think this is the problem


so take this code and if u have any problem send me

Huara
06-17-2003, 07:42 AM
You had the reason, I changed the way than I saved the field,
and so I resolved the problem.
now I am proving the code you sent me, it seems interesting.
Thanks for your encourage.
Huara.