joshua magsino joshua magsino - 4 months ago 23
Vb.net Question

How to store images in SQL Server

I do know that there is a answer here

http://stackoverflow.com/questions/5613898/storing-images-in-sql-server


But I want to know these:


  1. I know how to save them programmatically, but I don't know what data type to save them? Could I still use
    image
    datatype when I have converted my images as image to 256KB? Or should I save them into filestream data type?

  2. What kind of fragmentation is the document about? In my scenario, I have 2k+ employees and counting, so that means my application would get bigger over time, If I saved the images as image, and did not followed the rules as stated by the research paper, would my images lose their intact picture? (e.g a picture with blue background somehow changes its color maybe?)

  3. Should I save it in the exact table of my employee details table? Or should I save it in a different table?

  4. Sorry but I did not really understand the NTFS thing, is it the RAM of my computer? Or the RAM of my server? And I am using a file server as my database, should I still convert my images or should I go with using
    image
    data type without the conversion?


Answer

If you want to save files of any type in SQL Server then you should use the varbinary data type. You would use varbinary(max) unless you know that the files will be small. You can then convert your images to a Byte array and save that to the database.

You can enable the FILESTREAM option on your SQL Server instance these days and it will then store the data outside the main MDF file although that will be transparent to your code, so you keep using the same queries as you would otherwise.

Comments