1

I'm currently battling to retrieve an image from SQL Server 2008 R2 in an asp web application using vb.net. The image is stored in the SQL Server 2008 R2 database as an image type. I've been researching for the past few days and can't seem to find anything solid on this topic. Apparently, the image has to be retrieved using a http handler, and then then image control's imageurl property needs to reference that?

What kind of item needs to be added to the project for this .ashx page?

Please can someone post me some code for both the http handler and the aspx page using vb.net.

Thanks in advance

1
  • 1
    Tip #1: drop the IMAGE type - it's been deprecated since SQL Server 2005. Use VARBINARY(MAX) instead Commented Aug 14, 2011 at 15:07

1 Answer 1

1

You don't have to use a HTTP handler - there are other ways to do this. But using an HTTP handler is an elegant and quite nice way to achieve this.

Read these resources - they should you step-by-step how to achieve this:

Sign up to request clarification or add additional context in comments.

4 Comments

Cool links! I would add that you don't need to register the handlers if you're using ASPNET 4.0. Also, set the IsReusable property to true if you're presenting multiple images, say in a grid :)
Thanks for the links. If it's not necessary though, what would you recommend is the easiest way? I just want to get it working and move on. It's been bothering me for quite a while
This site will never go live, so it's just for demonstration purposes
@Matt: basically, you could also do something like the second link shows - a direct Response.BinaryWrite into your response stream. That would render your images, too. Depends on how you need to display those images...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.