最好的方法保存/加载图片与.Net& SQL Server 2005? [英] Best way to save/load pictures with .Net & SQL Server 2005?

查看:138
本文介绍了最好的方法保存/加载图片与.Net& SQL Server 2005?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在销售产品的网页中处理产品图片的典型方式是什么?说我有一个数据库与书或计算机组件等,所有的都有自己的示例图片例如...我应该将它们保存为DB作为二进制数据,或以某种方式处理他们在代码中,将它们保存到一个目录到图片文件的相应链接是否保存到DB中的产品表中?

What is the typical way to handle product pictures in a web-page selling products? Say I had a database with books or computer components etc, all of which have their own sample pictures for example... Should I save them into the DB as binary data, or somehow handle them in the codebehind, saving them into a directory with the appropriate link to the picture file being saved into the product table in the DB?

我想做一个销售公司的例子,虽然我可以想出

I'm trying to make a sales company example, and while I can come up with ways to do this, I wonder what is the typical norm used in the programming business?

更新:存储在另一个系统或备用DB上是不是一个选项,而关于可能的备选方案的信息供未来参考。所有我可以使用的是Visual Studio 2008和SQL Server 2005/2008,在一台计算机上,一个ASP.Net项目。因此,文件必须保存到网页项目中的目录中,或保存到正在使用的一个数据库中。

Update: Storing on another system or alternate DB's is not an option, while the information on possible alternatives for future reference is appreciated. All I have available to are Visual Studio 2008 and SQL Server 2005 / 2008, on one computer, with one ASP.Net project. So the files would have to be saved into a directory within the web-page project, or into the one DB being used by it.

推荐答案

在文件系统上但在数据库中保存文件

将文件保存到数据库中使其成为所有应用程序数据的单一备份点,并为应用程序创建一个较小的安全表面,因为

Saving files on filesystem but inside a DB
Saving files into DB makes it a single backup point for all your application data and makes a smaller security surface for your app because you don't need a write permission folder for storing files.

使用SQL Server 2008 Microsoft引入了一种称为 FILESTREAM 的新数据存储机制,将数据作为常规文件存储在文件夹中。但是您可以通过表访问它们(并存储其元数据)。您可以将文件存储为varbinary(max),并将它们存储在配置的文件系统上。这些文件也将被数据库备份过程拾取。这样,您就可以在单一解决方案中获得两个世界中最好的

With SQL Server 2008 Microsoft introduced a new data storage mechanism called FILESTREAM that stores data in folders as regular files. But you can access them (and store their metadata) via tables. You can store files as varbinary(max) and they get stored on the filesystem as configured. These files will also get picked up by DB Backup procedure. This way you get the best of both worlds in a single solution.

阅读它此处


我们必须指出,问题的作者没有提到他们可能使用SQL Server 2008,好处。这是唯一的原因,这个答案是与版本2008相关,因为这真的是他们的问题的最佳解决方案。

这篇关于最好的方法保存/加载图片与.Net& SQL Server 2005?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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