Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 43,876 times

Related Categories

Showing multiple images stored in a database

This sample demonstrates how to display multiple images from a table in a database. I had a table in my SQL Server database named "TestImage", which contained 2 fields "ImageID (auto number)" and "Image( Image)". I created 2 files, loadimage.asp and showimages.asp

LoadImage.asp

<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select image from advertisements where ad_id='"& request.QueryString("ad_id")&"'",conn1

if not rs.eof then
response.BinaryWrite rs("image")
end if

rs.close
set rs=nothing
%>

ShowImages.asp

<%
set rs=server.CreateObject("adodb.recordset")
rs.open "select ad_id,image from advertisements",conn1,1,2
if not rs.eof then
  do while not rs.eof
    If not isnull(rs("image").Value) Then
%>
<img src="loadimage.asp?ad_id=<%=rs("ad_id")%>">
<%
    end if
    rs.movenext
  loop
end if
rs.close
set rs=nothing
%>

I am from karachi, pakistan and working as a web developer in Creative Chaos Pvt Ltd, Karachi, Pakistan.Visit my personal website at http://itzimran.cjb.net. I have: DAWN Online Classified http://www.dawnclassified.com Mehboob Hamza Gems http://www.mhgems.com Princeton Review http://www.princetonreview.com.pk Mohammad Farooq Textile Mills http://www.mohammadfarooq.com Engro Chemicals http://www.engro.com Maple Ltd http://www.mapleltd.com DAWN Online Classifieds http://www.dawnclassified.com Amatech Inc http://www.amatechonline.com Filters Pakistan http://www.filterspakistan.com The Thinkers Gillian Rogerson Interior Decoration & Design http://www.gillianrogerson.co.uk

Comments

  • Help me in storing image in web server through cli

    Posted by pinga506 on 12 May 2004

    Any one can help me with code to insert image in web server SQL data base through client mechine on web. please let me know in ASP. Thanks.:)

  • Posted by James Crowley on 09 Mar 2004

    There is also a tutorial here: http://www.developerfusion.com/show/3905/

  • Posted by amoibade on 02 Oct 2003

    Thank you very much for your help, i will try it as soon as possible...

  • Store Image In Database...

    Posted by itisimrankhan on 02 Oct 2003

    You Will Need :
    HTML Form with a File field and Form's Encrypt Type set to multipart
    ASP Code to read binary data and store somewhere..
    Use recordset.appendchunk method to store binary data in data...

  • Store image in database

    Posted by amoibade on 20 Sep 2003

    Well... But begore this, how can i store an image into a database?