473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Displaying Images From An SQL Database in a WEb Page

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
2 1750
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Vinay | last post by:
Hi All: I have a small application that stores images either in the database or as files (depending on the user preference). I'm in the process of providing a web interface to this application....
3
by: Irfan Akram | last post by:
Hi Guys, I am having problems displaying an image from the database, that alreday has been uoploaded successfully. The image loads in correctly, but by default it is displayed on the whole...
3
by: CLEAR-RCIC | last post by:
I have several images i want to display in an ASP.Net application. The images are being passed to me in binary format from another application. Is there a good way to write them directly to an...
1
by: David Lozzi | last post by:
Hello, I'm wondering whats the best method to use for displaying several photos' thumbnails. One method I know is to dynamically resize the photo at the time the page is loaded. What does this...
3
by: CD | last post by:
An application is logging faxes sent in SQL2000 image column type. I have found code on the net but what it is doing is prompting to save to local which is fine for single page image. Not good...
8
by: Lloyd Sheen | last post by:
I have a list of JPG's which are found in a SQL Server database. When the page selects a certain piece of data it will refer to the file system (resident on IIS server with a virtual directory)...
10
by: gnewsgroup | last post by:
I've googled and tried various approaches, but could not resolve this problem. The article at MSDN: Displaying Images in a GridView Column only presents a simple case where all data (including the...
4
by: redpears007 | last post by:
Hi Again, Throwing this one out to you again as i am not getting anywhere and can find little to no information out there. I am currently displaying images (Jpegs) in access via the routine...
5
by: asharda | last post by:
Hi, I have an ASP.Net application with the back-end as VB.Net. I have a combo control and on the selection changed event of the combo control I need to get the selected image from the database...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.