Advice needed: reading image (binary) data from a db, to be placed in an Image control ??

  • Thread starter Thread starter Denise Smith
  • Start date Start date
D

Denise Smith

Hello,

I'm wondering if anyone can help me out here?

I want to be able to browse records in a database where one of the
fields contains an image.

I think I might have to extract the image to a byte array, write it to
a temp file then refer to the temp file as the URL source for the
Image control.

I've been trying this method, but I'm stuck on a couple of points.

1. The ImageURL property is not being written to the page when it gets
to the browser, and

2. I'm having trouble writing the byte array to a file on disk.

Am I going about this the wrong way?


-Denise
 
You don't need to write a byte array or anything else to a disk. Just create
an ASPX page that grabs the binary data, converts it to an in-memory Bitmap,
sets the Response.ContentType property to "image/jpg" and streams the image
to the client in the Response.OutputStream. Then the URL of this ASPX page
can be the source of an HTML Image tag, as in:

<img src="image.aspx">

--
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top