Vive Corp.
     Displaying images on the web page
Services Products Support Downloads Contact Us About Us Site map

Software Development

Since 1991

    Displaying images using ASP:          
Retrieving image from a database is much easier task if you compare it to uploading. Here is ASP script you can use to get the image from the database and put it on your web page.

ASP page (for SQL Server)


 if request("name") = "" then Response.End

 ' Clear out the existing HTTP header information
 Response.Expires = 0
 Response.Buffer = TRUE

 ' Change the HTTP header to reflect 
 ' that an image is being passed.
 Response.ContentType = "image/gif"

 query = "select Picture from temp_image where File_Name = '" 
 	& Request("name") & "'"
 set Connection = server.createobject("ADODB.Connection")
 Connection.Open "Provider=SQLOLEDB; Data Source=server; 
 Initial Catalog=dbname; User ID=user; Password=password"

 set rsBlob = Server.CreateObject("adodb.recordset")
 rsBlob.Open query, Connection, 2, 3

 if rsBlob.eof then Response.End
 if isnull(rsBlob(0)) then Response.End

 Response.BinaryWrite rsBlob(0)
 Set rsBlob = Nothing

To make your web page work with this script you need to insert the following code into your html page:

<IMG SRC="getPicture.asp?name=test.gif">


Download Image2db

Displaying images using Perl

Services | Products | Support | Downloads | Contact Us | About Us | Site Map
Copyright 1998-2007 Vive Corp. All rights reserved.