How to store files(.doc files,.zip files) in a database and how to retrieve them.
Thanks in advance.
How to store files(.doc files,.zip files) in a database and how to retrieve them.
Thanks in advance.
If you use Microsoft SQL Server 2008 there is FileStream datatype.
If you use Microsoft SQL Server 2000/2005 the optimal solution is to save file path rather file itself.
You can save any size file, or image or anything else that you want into an SQL database.
This capability has been around even back when SQL was SyBase.
The Text field is a BLOB field. Use a byte[] array, and stream the file into the field through a memorystream or filestream. When you want to get it back our, again, use a byte array to stream it out. Check out how to store and retireve images, and you use the same method for files.
There are lots of document companies that store zip files, PDF, and Word Doc files (and other types) directly into SQL databases. Storing to the hard drive is not a good option because it opens a security hole if the customer has to have a network share to retireve the file.
Jerry
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.