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:
RoomPhoto_ID
RoomPhoto_Photo
TenancyAgreement_ID (FK from TenancyAgreement table)

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

Thanks in advance
bpsp10Asked:
Who is Participating?
 
TomasPCommented:
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
0
 
Ephraim WangoyaCommented:

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

Also look at the new FILESTREAM feature in SQL 2008, its meant for exactly what you are trying to do
http://msdn.microsoft.com/en-us/library/cc716724(v=vs.90).aspx
0
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?

Thanks
0
 
TomasPCommented:
Here is some background and some sample code
http://technet.microsoft.com/en-us/library/cc949109(SQL.100).aspx
0
 
teodor bircaCommented:
I recommend you to read this:
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_24248735.html
I don't think is a good practice to store the photo inside database.
0
 
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.
0
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.