0

I am trying to store references of images in a SQL Server DB and store the actual images in a file server/folder. I am hoping someone could give me a link or code example on how to do this. I don't want to store BLOB in the database.

I am using ASP.NET/C# to handle this.

rae1
  • 6,066
  • 4
  • 27
  • 48
  • 8
    What's wrong with storing the path to the image? – RonaldBarzell Dec 12 '12 at 17:00
  • You have to be more specific as to what you've done, and why it doesn't work. As it stands, it is a very generic question. – rae1 Dec 12 '12 at 17:20
  • Sorry for not being clear I guess. My goal was to actually store the path only in the DB and reference the path from code when called. I am trying to get away from storing the image as a binary. – Courtney Smith Dec 12 '12 at 18:04

4 Answers4

0

All files in a folder have unique names, so I think you shouldn't worry about storing the path of the image, as suggested in the comments. If you are worried about consistence, i.e. someone deleting a "referenced" image or inserting a path to nonexistent image file, you could check that either from your application, or even from the database itself.

However I would not hesitate to use a blob, you can use MS SQL 2012 and insert the image files to a file table, which sounds quite convenient.

Honza Brestan
  • 10,637
  • 2
  • 32
  • 43
  • I haven't tested that, but as the output cache stores really the result of the request processing, it should work with images stored in a blob as well. I don't have any proof though. – Honza Brestan Dec 12 '12 at 17:27
0

as per my knowledge.or my expirence the images are stored in sql server that is in image datatype feild.it is stored in byte format.that is actlly the reference of the actual image.hope this link help you to get more clear idea about it

http://www.sqlhub.com/2009/03/image-store-in-sql-server-2005-database.html http://www.codeproject.com/Articles/10861/Storing-and-Retrieving-Images-from-SQL-Server-usin

0

Use a HttpHandler to grab the image from the database and use the Image data type:

Retrieve image of image control as byte array which is set using generichandler(.ashx)?

Community
  • 1
  • 1
IrishChieftain
  • 15,108
  • 7
  • 50
  • 91
0

Storing images in your dataase or in a filestream, totaly depends on your images size. In Microsoft Research there is a good paper called To BLOB or Not To BLOB.

After a lot of test and much analysis;

  • If your pictures are below 256K, store them in datebase VARBINARY column is good.
  • If your pictures are over 1 MB, storing them in the filesystem is good.(With FILESTREAM attribute, they are still under transactional control and part of the your database)
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364