Click to See Complete Forum and Search --> : display images in database through Response Object In Asp
prasad
May 6th, 2000, 01:26 PM
How to display images stored in database through
Response object.(Suppose image is stored in
Access Database)
heptite
May 7th, 2000, 06:09 AM
Originally posted by prasad
How to display images stored in database through
Response object.(Suppose image is stored in
Access Database)
The best thing to do is to store the location of the graphic files in your database, and use the location of the graphic file with your response object.
I do this with .pdf files all the time. The location of the .pdf file is stored in the database, and I use that text string to create a link to the .pdf file.
Sue
Rather than giving you an opinion how 'bout an answer? The following assumes that you already have the images in sql server or access:
<%
Dim rec
Set rec = Server.CreateObject ("ADODB.Recordset")
' picId is whatever you use to identify your records
rec.Source = "SELECT picPhoto, picId FROM picData WHERE picId=3"
' Assume you already have an open connection named 'cn'
rec.ActiveConnection = cn
rec.Open
If Not (rec.BOF And rec.EOF) Then
Response.ContentType = "image/jpeg"
Response.BinaryWrite rec("picPhoto")
Else
Response.Redirect "YourErrorPage.asp"
End If
rec.Close
Set rec = Nothing
%>
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.