By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,630 Members | 1,166 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,630 IT Pros & Developers. It's quick & easy.

Displaying Images From An SQL Database in a WEb Page

P: n/a
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
Sep 2 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

"Just Me" <news.microsoft.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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

Sep 2 '07 #2

P: n/a

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

"Just Me" <news.microsoft.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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

Sep 4 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.