VB.NET - Saving an image into SQLCE - Asked By Tony Reilly-Cooper on 09-Apr-13 09:09 AM

Afternoon guys and girls. 

Any chance you can shed some light on to this for me. 
I have a form where users details are entered in e.g. name, role within business etc.
I can get these items of information to save into the database but I cant work out how I can get an image to save into the database. 
I want to be able to search for an image probably using an open file dialog and then when i hit save on the form it will save that image into the database to load as part of their profile later? 

Any ideas would be greatly appreciated! 

Cheers
Tony
Robbe Morris replied to Tony Reilly-Cooper on 09-Apr-13 01:19 PM
You have to convert the image to and from a byte[] in order to store the byte[] in a blob/ntext/varbinary type column in SQL.  I don't use SQLCE, so I'm not 100% what types are available in the version you are using.  You'll have to modify this C# code to VB.NET

http://www.eggheadcafe.com/sample-code/csharp.NET/6fe73a13-2a8e-4f2a-a6c4-fa76b9bb1715/convert-image-to-byte-in-net.aspx

http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=799