Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Store/Retrieve Images In SQL Table
Message
De
17/02/2010 06:52:27
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
17/02/2010 04:36:45
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01449388
Message ID:
01449405
Vues:
51
>>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform