See image from northwind

A

alberto

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

Olaf Rabbachin

Hi,
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
 
A

Alberto

IEl 01/03/2010 15:51, Olaf Rabbachin escribió:
Image.FromStream(dr.GetSqlBytes(3).Stream) > Hi,
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
 
O

Olaf Rabbachin

Hi Alberto,
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
 

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

Top