Click here to Skip to main content
Click here to Skip to main content

Get an SQL Server blob field and show it in an PictureBox using VB.Net

By , 27 Sep 2010
 

I assume that the data has been read into a dataset!

To read an sql blob field into a picture box, just do this:

'create a PictureBox or use the one on your form!
Dim pic As New PictureBox
'rs is the record set.
'.ImageContent is the field name containing the blob field.
'here is the catch, assign the blob field directly into an array of Byte
Dim img As Byte() = rs.ImageContent.ToArray
'write the array content into memory 
Dim ms As New MemoryStream()
ms.Write(img, 0, rs.ImageContent.Length)
With pic
   'assign some other properties here
   '
   'read the converted blob image into the picture box
   'use overload option one!
   .Image = Image.FromStream(ms)
End With

That's all!

I hope it's use full

Willem Hijlkema

the Netherlands

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Willem Hijlkema
Netherlands Netherlands
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 27 Sep 2010
Article Copyright 2010 by Willem Hijlkema
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid