Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Store/Retrieve Images In SQL Table
Message
From
18/02/2010 11:38:56
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01449388
Message ID:
01449729
Views:
57
Just in case - may be important to know about this little problem

http://beyondrelational.com/blogs/jacob/archive/2010/02/18/why-do-excel-2007-prompt-for-repair-when-opening-a-document-stored-in-sql-server-2008-filestream-column.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+ExploringBeyondRelational+%28Exploring+Beyond+Relational+.......%29

>>>>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).
>
>Hi,
>Excellent point about the FILESTREAM storage option in SQL2008 - in many ways perhaps the best of both worlds. I remember reading about it but we have to support a large number of SQL2005 (or even earlier) versions so it wasn't really an option. Going back for a refresher I came across these pages which gives a good view of the pro's and con's of the various options:
>http://msdn.microsoft.com/en-us/library/cc949109.aspx
>http://research.microsoft.com/apps/pubs/default.aspx?id=64525
>
> Nothing there to change my view that varbinary was the best solution for my current needs tho.....
>Best,
>Viv
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform