>>What's involved in storing and retrieving images in a SQL table into a PictureBox on a WinForm?
>
>To answer the question without making a judgement on whether it's a good idea (and I don't neccessarily agree with Michel/Kevin on this):
>
>The image can be stored in a SQL varbinary field. In C# this appears as a byte array (byte[]). You will need to convert this to a BitMap which can then be used as the Image property of the PictureBox. There are several ways of handling the conversion - here's one:
public System.Drawing.Bitmap GetBitMap(byte[] b)
> {
> using (System.IO.MemoryStream ms = new System.IO.MemoryStream(b))
> {
> return (System.Drawing.Bitmap) System.Drawing.Image.FromStream(ms);
> }
> }
>HTH,
>Viv
I would second on that. I too prefer using varbinary if it is 2008 or later.
Starting with SQL2008 there is a FILESTREAM attribute for this purpose. The image (or any binary data) is stored externally on disk and still it is handled by SQL server. To the client it is just any other varbinary(max) column (and can also get direct streaming access if allowed to do so).
Cetin