Hossein Moradinia
Hossein Moradinia

Reputation: 6244

Save files into a database

I want to save files into a database in my C# Windows application. What database technology should/could I use?

I want to be able to save files and open saved files with my application.

Upvotes: 1

Views: 1535

Answers (4)

marc_s
marc_s

Reputation: 754348

If you're dealing with Microsoft SQL Server, there's a really interesting performance comparison done by Microsoft Research:

To BLOB or not to BLOB

Their conclusion basically is:

  • if your files are mostly 256 KB in size or less, store them inside the database
  • if your files are mostly 1 MB or larger, store them in the file system and only store a reference to them in the database (e.g. using the FILESTREAM feature in SQL Server 2008)
  • if your files are mostly between those two sizes, it comes down to other factors, like frequency of update, hardware available and so forth

And if you should ever need to store a file larger than 2 GB, storing it in the filesystem is your only choice, really. So that might also be a deciding factor.

Upvotes: 7

Rob
Rob

Reputation: 45761

Storing actual files into the database is probably not the best approach as there's somewhere designed to store files and do it well already, it's called the file system :)

That said, if you can use Sql Server, you could take a look at FILESTREAM storage as it's a sort-of midpoint between the two.

Upvotes: 3

Yoram de Langen
Yoram de Langen

Reputation: 5499

Look at this page. There is a example of open a file and save..

so you can implement your own code for saving it to a database?

if you wanna save text i would recommand to use a SQL server or Oracle database, ive learned to program c# and SQL server but learned the theory of Oracle

Upvotes: 0

Gunner
Gunner

Reputation: 917

Most modern databases will allow you to save binary data in them. ie in SQL server you have blob type where you can store any binary data you like.

Upvotes: 0

Related Questions