You can extract the binary data from the database of the image, make sure you append the correct format of the file, and then display the file inside the
img
element. One thing that you should know, is that the file would be in binary form, so you need to write the binary in the form of a file (and appending the file format too),
Response.ContentType = file.MimeType;
Response.BinaryWrite((byte[])file.FileContent);
Above code does that. It sets the content type to the response; file, and then writes the binary data to the response; thus your file.
The
article[
^] that you should be interested in reading. The article contains all of the code and explaination required for this process. You can add a WHERE clause to extract the files for only the current user id. Such as the following code,
SELECT * FROM Images WHERE UserId = 2
Or what so ever UserId; might be passed by a parameter.
A very personal tip to you, never ever store your files in the data for a social website. There would be a lot of users storing their files, and the space of the database is very expensive; unless you've bought the SQL Server's Web edition for a space of multiple PBs. Users would upload their data to the server, and the space would be used in the database, instead you should always store the files in the file system, and just store the file's path to the database's table. This would ensure that the database's space is not being used where it should not be used.