How to get image from a database when image store in varbinary format .
take a look .........
1. create table in database insert the value first , with the help of application.
please follow my pervious example how to store an image in table varbinary format.
here is the Link :- http://technicalviewpoint.blogspot.in/2016/07/how-to-store-image-in-database-table.html
I already have a table Name Images with Values.
Model and dbContex are already Created in previous session name Images
2> Now we create an View for fetch Image through database.
Image Convertion logic from varbinary datatype
var getimage = Convert.ToBase64String(item.Picture);
var picture = string.Format("data:image/jpeg;base64,{0}", getimage);
<img src="@Url.Content(picture)" width="100px;" height="100px;" /></td>
4> Image will Visible..
Thank you friends..............
take a look .........
1. create table in database insert the value first , with the help of application.
please follow my pervious example how to store an image in table varbinary format.
here is the Link :- http://technicalviewpoint.blogspot.in/2016/07/how-to-store-image-in-database-table.html
I already have a table Name Images with Values.
In Picture field data look like <Binary data>
Now we convert <Binary data> to ImagesModel and dbContex are already Created in previous session name Images
2>Controller also created in early session ImagesController, Now Add new Action name is GetImage.
2> Now we create an View for fetch Image through database.
Image Convertion logic from varbinary datatype
var getimage = Convert.ToBase64String(item.Picture);
var picture = string.Format("data:image/jpeg;base64,{0}", getimage);
<img src="@Url.Content(picture)" width="100px;" height="100px;" /></td>
3> Now Run the project
Thank you friends..............