Does anyone know an example of storing an image in a SQL Server CE database?
What type of data should the column be? (I guess the binary.)
I am using Linq-To-Datasets. Can I use this to put an image in a database and pull it out later?
Thanks for any advice.
Here is how I did it:
MemoryStream stream = new MemoryStream(); myBitmapImage.Save(stream, ImageFormat.Png); myInsertLinqToDataSetRow.IMAGE_COLUMN = stream.ToArray();
To download it back, I did the following:
MemoryStream stream = new MemoryStream(myLinqToDataSetRow.IMAGE_COLUMN); myBitmapImage.SignatureImage = new Bitmap(stream);
I found a page on MSDN that said the "Image" column type was leaving and that you should use varbinary (MAX). Max is not supported by SQL Server CE, so I did varbinary (8000).
LATER NOTE: although varbinary (max) is not supported by SQL Server CE. Varbinary (8000) is not enough for many images. In the end, I used the image type, although it is not recommended. After ms offers a resonant alternative on a mobile platform, I will consider switching.
c # windows-mobile sql-server-ce compact-framework linq-to-dataset
Vaccano
source share