What's the best way to store an image in a database in binary format, and how can I implement it using C#?
2 Answers
If you are using SQL Server, you can use the Image column type.
5 Comments
Damien_The_Unbeliever
image is deprected (msdn.microsoft.com/en-us/library/ms187993.aspx). varbinary(max) is to be prefered for new development work.Panjiyar Rahul
what this BLOB column actually meant
Panjiyar Rahul
IS it meant the binary to used ... i use image column. what it differ
Panjiyar Rahul
varbinary or binary whats the difference??
FarligOpptreden
Binary is fixed length, whereas Varbinary is variable length. This article explains it quite nicely: msdn.microsoft.com/en-us/library/ms188362.aspx
You can find the answer to converting your image to binary here:
You would need a BLOB column in your SQL database in order to be able to insert it.
EDIT:
If you want to retrieve it back from the database, you can use the following article to do so:
2 Comments
Panjiyar Rahul
why image column will not use for that?
Steven Ryssaert
I suggested a way to store it in binary format, as you asked. I have no experience with the Image column type, I store it in this BLOB - binary format, or as a Base64 encoded string.