Image Loading from SQL Server

G

Guest

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.
 
M

Michael Nemtsev

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?
 
E

Eliyahu Goldin

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
 
P

Patrice

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).
 
G

Guest

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"...
 
P

Patrice

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...
 

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

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top