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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ephraim WangoyaCommented:

its better to store the image outside the database and store the file path in the DB
0
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.