Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Store Image references in access dB and display in ASP

Status
Not open for further replies.

Webflex

Technical User
Apr 20, 2001
101
GB
Hi

Can anyone point me in the direction of a decent clear explanation that describes how to store an image url / link in an MS Access database and display it when called from an ASP page.

I have tried various methods found at 4 Guys / Aspin etc and have ended up with a display of true instead of the image so I'm obviously interpreting something wrong.

Instead of dissecting the method I am using which I have tried to do here but it keeps getting bogged down I'd like to start from a clean sheet approach.

TIA
Webflex
 
Easiest way would be something like this

<%
SQL = &quot;Select folder, file_name from Images where owner_name = '&quot; & User_name & &quot;'&quot;
rs.open SQL, conn
%>
<html>
<body>
<img src=&quot;../<%=rs(&quot;folder&quot;) &&quot;/&quot; & rs(&quot;file_name&quot;)%></img>
</body>
</html>

This assumes that you already have your recordset and connection objects created, and that you are storing the pictures in relation to the user of the page.

What happens here is that you are going to the database and selecting the folder and file_name of the image you want to select. Becuase this is processed first by the server, you can then use these values to hand back to the page as the src for your img tag. That way when the server tries to create the image, it sees only the result of the recordset, and that is where it tries to find the image.

There are two advantages to doing it this way. 1. It won't cause the page not to load if the image isn't found, it will simply not show a image. 2. You can always view the source of the page in the browser to see exactly what is being selected from the database so you can make sure you query is correct, or that you have the right syntax.

Let me know if this helps.
 
Thanks, looks useful, I'll go away and give this a try.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top