How to upload a photo to MS SQL using C# ASP.NET

Hey guys,

I would like to use my C# application to store images.

I suppose the best way is to make it so the image gets moved to the \\Images folder for the application and then the Database stores the file path? Or would it be better to store the image in the database itself?

I have table RoomPhoto with fields:
TenancyAgreement_ID (FK from TenancyAgreement table)

What is the best way to do this and how would I do it?

Thanks in advance
Who is Participating?
If you want to treat the \\images folder as a cache for the database to save a trip to the db then a copy placed there is fine. However, if you want to insure that the image is the image placed into the database then just push the image to the database in a background thread.
The solution depends on whether you want the user to be able to view the images without the application running also, if so then use \\images
Ephraim WangoyaCommented:

its better to store the image outside the database and store the file path in the DB
Ephraim WangoyaCommented:

Also look at the new FILESTREAM feature in SQL 2008, its meant for exactly what you are trying to do
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

bpsp10Author Commented:
Ok thanks for the advice..... now the hard bit....

How would I go about doing this? Any examples for code?

Here is some background and some sample code
teodor bircaCommented:
I recommend you to read this:
I don't think is a good practice to store the photo inside database.
Guy Hengel [angelIII / a3]Billing EngineerCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.