使用Asp.net将图像保存在数据库中 [英] save Image in database using Asp.net

查看:80
本文介绍了使用Asp.net将图像保存在数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用ASP.net在MSSQL服务器中保存大量的图片,哪种方法最好,以下为什么?

(1)在数据库中保存图像路径。

(2)将数据保存在数据库中。

I want to save large number of pics in MSSQL server using ASP.net which method is best from the following and why?
(1)Save image path in database.
(2)save image in database.

推荐答案

对于大图像,最常见的解决方案是将(唯一的)文件名存储在数据库中,并将文件本身在服务器端的文件系统中。



我将减少数据库负载和性能负担,允许ASP.NET应用程序直接将文件作为静态对象提供,无需数据库访问。此外,文件的物理存储可以在不同的计算机上,而不是在运行HTTP服务器的计算机上。



将所有文件存储在数据库中的一些好处将是更好的数据完整性。例如,您不需要单独备份数据库和单独备份映像文件。您不需要检查数据库是否与文件存储完全同步,这可能不是由于某些硬件故障造成的。嵌入在RDBMS中的事务机制不涉及外部文件存储,因此您需要单独处理完整性。



-SA
For big images, most usual solution is to store (unique) file names in a database, and files themselves in a file system of the server side.

I will reduce the database load and burden on its performance, allow ASP.NET application to serve files as static objects directly, without a need for database access. Also, the physical storage of the files could be on a different computer, not the on the one running the HTTP server.

Some benefit of storing it all on database would be better data integrity. For example, you would not need to backup database separately and image file storage separately. You won't need to check up if the database is perfectly synchronized with the file storage, which may not be the case as a result of certain, say, hardware faults. The transaction mechanism embedded in a RDBMS does not involve external file storage, so you would need to take care of the integrity separately.

—SA


请参阅:



在DB中存储图像 - 是或不是? [56 answers] [ ^ ]



做或不做:将图像存储在数据库中 [ ^ ]
See these :

Storing Images in DB - Yea or Nay? [56 answers][^]

To Do or Not to Do: Store Images in a Database[^]


这篇关于使用Asp.net将图像保存在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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