如何保存图片到数据库? [英] How to save picture in the database?

查看:104
本文介绍了如何保存图片到数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在LINQ to SQL的,WPF和我有一个数据库,现在我需要保存在数据库中的一些图片,但我不知道这是正确的数据类型,保存图片数据库(该数据库将连接从10个用户在同一时间)。 你能以正确的方式来克服这一步指向我? 如果我没有错了,它是不是一个好主意保存在数据库中的照片,但如果你能指点我一个更好的方法,我将应用它。 非常感谢您的时间。

i'm working on Linq To Sql,WPF and i have a database now i need to save some picture in the database but i don't know which is the correct datatype to save the pictures Database(this database would be connect from 10 users in the same time). Can you point me in the right way to overcome this step? If i didn't wrong it is not a good idea to save pictures in the database but if you can advice me a better method i will apply it. Thanks so much for your time.

尼斯问候

推荐答案

您可以使用VARBINARY(MAX)或图像列类型。 LINQ2SQL会自动生成一个使用二进制对象来包装你的形象的一类。二进制对象只是一个围绕一个字节封装[]。

You can use a 'varbinary(MAX)' or 'image' column type. Linq2Sql will auto-generate a class that uses a Binary object to wrap your image. The Binary object is just a wrapper around a byte[].

myObject.Image = new Binary(imageByteArray);

这篇关于如何保存图片到数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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