1,105,310 Community Members

display image from MS Access Database using HTML / ASP

Member Avatar
vindom
Light Poster
47 posts since Feb 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi
I've ms database where I've added one image(one so far for testing). Also in that DB(database) I have UserID and ItemID. Image I've added to DB (.mdb format) manually as OLE object. (It was : right click on DB field / Insert Object / from file/ picked up a picture / ok / done)
Now.. I'm trying to display that picture to a webpage using ASP code. The code I'm using to "pull" that image out is

'Declare Variables..
    Dim sql
    Dim rs
    Dim conn

    
   'Instantiate Objects
   Set conn = Server.CreateObject("ADODB.Connection")
   Set rs = Server.CreateObject("ADODB.Recordset")
   
   'Open connection
   Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ 
             "Data Source=" & Server.MapPath("GUDB.mdb")
   
   'Get the specific image based on the ID passed in a querystring
    str = "SELECT fil FROM Items"
    rs.Open str, conn,3,3
    if rs.eof then 'No records found
        Response.End
    else 'Display the contents
        Response.ContentType = "image/bmp" 
        Response.BinaryWrite(rs("fil")) 
    end if
   
   'destroy the variables.
   rs.Close
   conn.Close
   set rs = Nothing
   set conn = Nothing

to display that pulled out picture on the next page I use

<IMG SRC="gal.asp">

But nothing happens... I've tested piece of code that pulls image out from DB - it works, the code finds it, but obviously can pass that to a next page where second small part of code should handle it. The small part of the code for displaying that JPG (or BMP - I've tried both) displays tiny icon with 3 color circles in it - what suppose to be a picture I guess....
Any help would be great .. :-) Thanks!

Question Self-Answered as of 1 Year Ago
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: