views:

94

answers:

3

Hi all,

I would like to store images in database by converting them in to binary objects or i will store them in to a temp folder and will save the path in my database. But i am unable to do the programming so can any give me a sample code to save images in to sql database using Asp.net.

A: 

better to store image in a folder and save the path in database, which would be much faster than saving in database.

Note dont use datatype image, which is going to change form database itself : read this

anishmarokey
But that does make backups a pain. The nice thing about storing them as a blob is everything for the app is in the db, not strewn across a file-system.
Byron Whitlock
Not really: you have no way of enforcing links or that files/data matches. This is only a solution if you really care about the quality and integrity of your data.
gbn
SharePoint stores everything in the database, including images and large documents. So I would say it's totally possible and would make maintenance tasks like backups much easier. And with the new FILESTREAM support in Sql 2008, performance shouldn't be much of an issue.
ShaderOp
-1.... especially the backup integration can be painfull. Plus, with 2008R2 upward (suggeted update) you can store them in the database... in the file system.
TomTom
A: 

Store the images path on DB instead of storing as Binary, because it hurts performance. In SQL server, BLOB datatypes are stored in seperate pages called LOB_data page and on data pages pointers will be linked with LOB_data page. You cannot create an index over BLOB data type also. Hence, it adversely affects the performance. Ideal solution would be to store the images in a shared drive and storing the image link in database.

banupriya
-1... another off topic answer, especially as storgin the images in the database is fully valid and has a lot of advantages. That is, unless you believe backups are something for stupid people and not for you. DB storage is the only way to take a fully integrated backup in just one place.
TomTom
if your concern is performance try to avoid storing images in database, or if you are on SQL Server 2008 then go for filestream but still you have to perform separate backups for filestream storage
banupriya
I have some filestream columns on my DB and they get backed up along with the database... Without doing anything else.
Carles
Database mirroring does not support FILESTREAM. A FILESTREAM filegroup cannot be created on the principal server. Database mirroring cannot be configured for a database that contains FILESTREAM filegroups.
banupriya
Repeating myself: Not really: you have no way of enforcing links or that files/data matches. This is only a solution if you really care about the quality and integrity of your data.
gbn