1.11M Members

display image from MS Access Database using HTML / ASP


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
    else 'Display the contents
        Response.ContentType = "image/bmp" 
    end if
   'destroy the variables.
   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 2 Years Ago
This question has already been solved: Start a new discussion instead
Start New Discussion
View similar articles that have also been tagged: