在SQL Server CE数据库存储图像 [英] Store an image in a SQL Server CE database

查看:222
本文介绍了在SQL Server CE数据库存储图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有任何一个对如何存储在SQL Server CE数据库图像的例子知道吗?

Does any one know of an example on how to store an image in a SQL Server CE database?

应该列是什么数据类型? (我猜的二进制文件。)

What data type should the column be? (I am guessing binary.)

我使用LINQ到数据集。是否有可能使用把图像到数据库,将其拉出再以后呢?

I use Linq-To-Datasets. Is it possible using that to put the image into the database and pull it out again later?

感谢您的任何建议。

下面是我做的:

MemoryStream stream = new MemoryStream();
myBitmapImage.Save(stream, ImageFormat.Png);
myInsertLinqToDataSetRow.IMAGE_COLUMN = stream.ToArray();

要回来了,我再次这样做加载:

To load it back out again I did this:

MemoryStream stream = new MemoryStream(myLinqToDataSetRow.IMAGE_COLUMN);
myBitmapImage.SignatureImage = new Bitmap(stream);



我发现在MSDN上一个页面,说,图像列类型会消失,而且你应该使用VARBINARY(MAX)。 ,不支持最大的SQL Server CE,所以我做VARBINARY(8000)

I found a page on MSDN that said that the Image column type is going away and that you should use varbinary(MAX). Max is not supported on SQL Server CE so I did varbinary(8000).

版本注:当VARBINARY(MAX)是不支持的SQL Server CE。 VARBINARY(8000)不是很多图像不够大。我没有最终使用的图像类型,即使它计划将弃用。一旦MS提供移动平台,我会考虑换一个合理的alternitive

LATER NOTE: while varbinary(max) is not supported on SQL Server CE. Varbinary(8000) is not big enough for many images. I did end up using the Image type even though it is planned to be deprecated. Once ms offers a resonable alternitive on the mobile platform I will consider switching.

推荐答案

下面是MSDN文章解释如何:

Here is an MSDN article explaining how:

http://support.microsoft.com/kb/318639

不幸的是,这个例子是在VB,但我相信你可以得到如何做到这一点的想法。

Unfortunately, the example is in VB, but I am sure that you can get the idea of how to do it.

我想说的二进制数据类型将是罚款用于存储图像。

I would say the binary datatype would be fine for storing the images.

这篇关于在SQL Server CE数据库存储图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆