如何在数据库中存储文件? [英] How to store a file in database ?

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

问题描述

嗨!

我想在SQL Server 2005数据库中存储文件(doc,pdf,...).
怎么做?

请给我发送示例代码.

谢谢.

Hi !

I want to store a file (doc,pdf,...) in SQL Server 2005 database .
How to do it ?

Please send to me a sample code .

Thanks .

推荐答案

看这篇文章...
http://www.akadia.com/services/dotnet_read_write_blob.html [
Look at this article...
http://www.akadia.com/services/dotnet_read_write_blob.html[^]


您有两个(或更多,我不知道)选项:
  • 将整个文件内容作为二进制对象(BLOB)存储在数据库中(深度复制").
  • 仅将文件路径存储在数据库中(弱复制" ").
You have two (or more, I don''t know) options:
  • Store the whole file content as a binary object (BLOB) inside the database (''deep copy'').
  • Store just the file path inside the database (''weak copy'').


查看此答案.图像,文件,实际上都是一样的.如果文件很大,请考虑使用流式传输,而不是此处建议的字节数组方法.

将图像存储在sql服务器中 [
See this answer. Images, files, all the same really. If you''ve got large files consider using streaming instead of the byte array approach suggested here.

Store images in sql server[^]


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

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