Display DB Image

  • Thread starter Thread starter C CORDON
  • Start date Start date
C

C CORDON

I have an image stored in a SQL DB how can I display it in a control on a
Windows Form?

TIA!
 
I have an image stored in a SQL DB how can I display it in a control on a
Windows Form?

TIA!

Well, I'm not too much of a db expert... But, what you are probably
ending up with is a feild in a dataset that amounts to a byte array -
assuming you are storing the actual image in the database. Once you
have the byte array, displaying that image in a PictureBox is actually
not that difficult... Actually, any setting any controls image
property...

You simply wrap the byte array in a System.IO.MemoryStream object and
call the Image.FromStream method. Here is some sample untested code...

Dim memStream As New MemoryStream (theByteArray)
PictureBox1.Image = Image.FromStream (memStream)

' you probably want to close the stream here...
memStream.Close ()

Anyway, HTH
 
I think I forgot to mention I am working on ASP.NET.

I got to the poit of loading the Byte() from the Image field in the table
but don´t know ehre to go from there.

Thanks anyway

:)
 
Back
Top