Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Image Loading from SQL Server

12 views
Skip to first unread message

Umeshnath

unread,
Jul 3, 2007, 8:42:10 AM7/3/07
to
Hi,
How can I load a image stored in SQL server database in ASP.NET page. I
have used Response.BinaryWrite but it loads in a new page .I want to load in
a part of my aspx page or in a control (image etc).
Is it possible to load in any grid control?

Thanks in advance
Umeshnath V.G.

Michael Nemtsev

unread,
Jul 3, 2007, 8:46:04 AM7/3/07
to
Hello Umeshnath,

I suppose u need to use ASP.NET AJAX to update your image in page without
updating all page

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

U> Hi,
U> How can I load a image stored in SQL server database in ASP.NET page.
U> I
U> have used Response.BinaryWrite but it loads in a new page .I want to
U> load in
U> a part of my aspx page or in a control (image etc).
U> Is it possible to load in any grid control?


Eliyahu Goldin

unread,
Jul 3, 2007, 8:52:00 AM7/3/07
to
You need to make a separate page GetImage.aspx that will accept an image id
as a query parameter. You will refer to your images like
<img src="GetImage.aspx?id=123" />

The page will get images from the database and stream them down with
Response.BinaryWrite. The images will land into the controls referring them.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"Umeshnath" <Umes...@discussions.microsoft.com> wrote in message
news:51A49F3C-B918-412A...@microsoft.com...

Patrice

unread,
Jul 3, 2007, 8:53:25 AM7/3/07
to
Do you know how to make it work with a usual image ? Do the same and then
change just the image url to point to the page that serves this image.

(the idea is that the control translates to an html img tag that points to
the image location, the image location can be a page that serves an image).

--
Patrice


"Umeshnath" <Umes...@discussions.microsoft.com> a écrit dans le message de
news: 51A49F3C-B918-412A...@microsoft.com...

Alexey Smirnov

unread,
Jul 3, 2007, 8:58:05 AM7/3/07
to
On Jul 3, 2:42 pm, Umeshnath <Umeshn...@discussions.microsoft.com>
wrote:

> have used Response.BinaryWrite but it loads in a new page

place your code in SqlImage.aspx and configure your Image Control to
call that page

<asp:Image ImageUrl="SqlImage.aspx"...

sloan

unread,
Jul 3, 2007, 9:36:14 AM7/3/07
to
http://msdn.microsoft.com/msdnmag/issues/07/03/wickedcode/default.aspx?loc=

You may have to google some, but Jeff Prosise puts the "Not So Good" label
on something like this:

<img src=<% SomePage.aspx?ID=123 %>

and suggests using a custom http module:
Find this files in the example listed above:

NorthwindImageGrabber.ashx 1 KB
PictureGridView.aspx 2 KB
PictureGridView.aspx.cs


This was fresh/cool stuff from TechEd2007 FYI.

"Umeshnath" <Umes...@discussions.microsoft.com> wrote in message
news:51A49F3C-B918-412A...@microsoft.com...

aspx.png
cs.png

Patrice

unread,
Jul 3, 2007, 9:51:55 AM7/3/07
to
Good point. From the top of my head this is because a high traffic site
would incurs the cost of creating a page instance when the whole page
infrastructure is actually not used at all in this case.

Also storing an image in SQL Server is not always the best strategy (you
could store just the image path and keep the image file itself outside of
the web site) or at least you could perhaps "cache" the image to avoid
reading it from SQL Server all the time... etc.. etc...

--
Patrice


"sloan" <sl...@ipass.net> a écrit dans le message de news:
eQsKhcXv...@TK2MSFTNGP04.phx.gbl...

sloan

unread,
Jul 3, 2007, 10:03:49 AM7/3/07
to

<img src=<% SomePage.aspx?ID=123 %>

I had pretty much the exact same thing in production, and went and redid it
after I got back.

........

Jeff Prosise rocks!
http://www.wintellect.com/TechnicalBioDetail.aspx?Tech=5

"Patrice" <http://www.chez.com/scribe/> wrote in message
news:eFu2SlXv...@TK2MSFTNGP03.phx.gbl...

0 new messages