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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DISPLAY GIF's from access to frontpage ( URGENT)

Status
Not open for further replies.

2IT

Programmer
May 6, 2002
2
TN
Hello
Could someone help me to show my images stored in OLE fromat
(access)
On my web pages I tried a VBScript script ( in frontpage), but when I add Response.ContentType = "image/gif"
it blocks .

This same script shows text from my database !!!!

Here's my script


<HTML>
<HEAD>
<TITLE>TEST MY DBASE</TITLE>
</HEAD>
<BODY>
<%@ LANGUAGE=&quot;VBSCRIPT&quot;%>
<p>
<BR><BR>
<P ALIGN=&quot;CENTER&quot;><STRONG><FONT SIZE=&quot;5&quot;>Lecture du contenu de la base</FONT></STRONG></P>
<BR><BR>
<%

Response.Expires = 0
Response.Buffer = TRUE
Response.Clear
Response.ContentType = &quot;image/gif&quot;
MaxSize = 100000

' open DB
Set BaseLink = Server.CreateObject(&quot;ADODB.Connection&quot;)
BaseLink.Open &quot;MYDBASE&quot;, &quot;&quot;, &quot;&quot;

' SQL
varSQL = &quot;SELECT * FROM myTable ORDER BY myrecord WHERE idprod = 1&quot;


'Baseset
Set BaseSet = Server.CreateObject(&quot;ADODB.Recordset&quot;)
BaseSet.Open varSQL, BaseLink


Do While Not BaseSet.EOF
%>

<P align=&quot;center&quot;><STRONG><% Response.BinaryWrite BaseSet(&quot;Photo&quot;)%></STRONG></P>

<%
BaseSet.MoveNext
Loop

' Close
BaseSet.Close
BaseLink.Close
Set BaseSet = Nothing
Set BaseLink = Nothing
%>
</BODY>
</HTML>
 
Hi there,

I was taught some time ago that it's not particularly good practice to store images directly within a database as it's deemed to slow performance, etc. Instead you should create a column within your table that contains the path to your images folder and image. A row in your db would simply read, images/my_pic_1.gif

You should, perhaps, just keep all your gifs in an images folder within your FrontPage web.

Then in your ASP code type something like this:

' --- SQL ---
varSQL = &quot;SELECT myImage FROM myTable WHERE idprod = 1 ORDER BY myRecord&quot;
(where myImage is the name of the column your reference all your images)

' --- Execute the SQL query ---
Set BaseSet, etc etc (as above)

' --- Get the image(s) from the recordset ---
image = BaseSet(&quot;myImage&quot;)

Then in your code where you wish to place your image type:

' --- Display the image ---
<%=image%>

The same principles should apply when wrapped in a loop.

Hope this helps, even if just a little.

Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top