Displaying Images From An SQL Database in a WEb Page

J

Just Me

Hi,

Im playing with this concept at the moment and was hoping to design an image
retreival system which would allow me to place images into the web page "
Where I want them", but draw them from the SQL Database.

I know how to get the image from the sql server, and I know one way of
writing the image to the page using BinaryWrite method of the reponse
object.

However, once you use BinaryWrite, it seems to obliterate eveything else.
What I need is to be able to render the page as I would normally do, but not
rely on images stored as files on a web server, or at least to generate the
URI' to them on the fly somehow. It seems a shame that when you getrecords
which you need to display pictures from that you have to go get them all
again jsut for the picture. An exampleof this would be a personell record, I
want to display the details about the person along with a pic, the pic is
retreived, but I can render the pic.

I might add here, that I am creating html content inside a aspx form by
using an htmlwriter object , this allows me to publish articles directly
fromt he database using custom formatting.

However, I am aware that the <img tag's src attribute seems to be limited to
either a URL which is a real URI or a more limited data:image//gid;base64 in
line type thing.

I think the asnwer is that you realistically cant do this in-line, and need
to store the images on disk.

Any responses which can confirm this or offer an alternative would be most
useful.


Thanks
 
T

Tom Dacon

The Personal Web Site Starter Kit would be a good place to look at one way
to do it. Search for that string on MSDN or the Microsoft site. Download it
and install it and bring it up in Visual Studio and look around. It has a
photo albums section that takes the images from a Sql Server Express
database.

Tom Dacon
Dacon Software Consulting
 
J

John Mott

You can do this:

<img src="http://mysite/imagefetcher.aspx?ID=3434"/>

where imagefetcher.aspx takes an ID of an image and renders it. Remember,
its the browser that calls back in to get the image data, you don't have to
generate it at the same time that you are generating the page.

i would also not store actual images in a database -- the file system is a
wonderful mechanism for storing files. of course, keeping a control record
for the image (with the filename as part of it) is a good idea so it can be
joined appropriately.

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top