From: alberto on
How can i see in a picturebox an image stored in the northwind database?
I'd like to show the field "photo" of the table Employee of Northwind. I
don't find a method of the static class Convert.

Thank you.
From: Olaf Rabbachin on
Hi,

alberto wrote:

> How can i see in a picturebox an image stored in the northwind database?
> I'd like to show the field "photo" of the table Employee of Northwind. I
> don't find a method of the static class Convert.

you'll need to apply a 78 byte offset to Northwind-pictures. Assuming that
"arrPicture" is a byte-array containing the NW-picture, you can do the
following (air-code/untested):

System.IO.MemoryStream ms = new System.IO.MemoryStream();
ms.Write(arrPicture, 78, arrPicture.Length - 78);
Image img = Image.FromStream(ms);
ms.Close();
YourPictureBox.Image = img;

Cheers,
Olaf
From: Alberto on
IEl 01/03/2010 15:51, Olaf Rabbachin escribi�:
Image.FromStream(dr.GetSqlBytes(3).Stream) > Hi,
>
> alberto wrote:
>
>> How can i see in a picturebox an image stored in the northwind database?
>> I'd like to show the field "photo" of the table Employee of Northwind. I
>> don't find a method of the static class Convert.
>
> you'll need to apply a 78 byte offset to Northwind-pictures. Assuming that
> "arrPicture" is a byte-array containing the NW-picture, you can do the
> following (air-code/untested):
>
> System.IO.MemoryStream ms = new System.IO.MemoryStream();
> ms.Write(arrPicture, 78, arrPicture.Length - 78);
> Image img = Image.FromStream(ms);
> ms.Close();
> YourPictureBox.Image = img;
>
> Cheers,
> Olaf
I've got the data in a SqlDataReader in the thirth column so I'm tryin
to read it in this way:

Image.FromStream(dr.GetSqlBytes(3).Stream)

but vs says that the parameter (I guess it is dr.GetSqlBytes(3).Stream)
it's no correct.

Thank you
From: Olaf Rabbachin on
Hi Alberto,

Alberto wrote:

> I've got the data in a SqlDataReader in the thirth column so I'm tryin
> to read it in this way:
>
> Image.FromStream(dr.GetSqlBytes(3).Stream)

just cast dr["Picture"] to a byte-array. I haven't tried this with the
Emp-table's Photo-column, but done so with Categories.Picture; both should
be just the same really.

Cheers,
Olaf