Results 1 to 3 of 3

Thread: display images in database through Response Object In Asp

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    india
    Posts
    3

    Question

    How to display images stored in database through
    Response object.(Suppose image is stored in
    Access Database)

  2. #2
    New Member
    Join Date
    May 2000
    Posts
    1

    Images and Databases

    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

  3. #3
    Guest
    Rather than giving you an opinion how 'bout an answer? The following assumes that you already have the images in sql server or access:

    Code:
    <%
    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
    
    %>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width