how to use images with your database

 

Access or other databases let you store images. but it is not as straight forward as you might wish to retrieve them for the web.

it can be done, theoretically. you find descriptions at pulling images form an Access DB or pulling images from a database on http://www.asptoday.com. but it would involve defining the MIME type of the image data properly and you would have to make this dynamic if you want to mix GIFs and JPEGs.

a much easier solution is to store the images not in the database but externally on your website and take advantage of the fact that HTML is pure text, containing only links to images.

an image embedded in a HTML code would look e.g. like the following:

<img src="myFolder/myImage.gif" width="324" height="83">

to make it dynamic you could replace the src string with ASP like the following:

<img src="<%=(Recordset1.Fields.Item("img").Value)%>" width="324" height="83">

"myFolder/myImage.gif" (or however the correct path would look like) would be what you would have to store in the appropriate field in the database.

if you look up the "Franchise" table in the scaalcoffe.mdb you will find a column that does this for the tutorial examples.

Ultradev offers a very easy way to apply this:
- create a recordset that contains the field with the image information
- import any image into the page and position it
- drag and drop the appropriate item from the data bindings window onto the image. Ultradev automatically replaces the src parameter with the ASP code.

 

 

 

1