I am creating a website in visual studio. I want retrieve and display image (of datatype image from sql server database) in webpage. I have a .cshtml page and got the following code to display some of the fields of the table. I am able to display everything except the image datatype column. I am using razor syntax.

MY code

@{
var db1 = Database.Open("database1");
var selectQueryString = "SELECT * FROM Recipes ORDER BY date";
}
<div class="left-content">
<h5>Recent Posts</h5>
 <table>
    <tbody>
    @foreach(var row in db1.Query(selectQueryString))
    {         
    <tr>
        <td>@row.image</td>
        <td>@row.title</td>
        <td>@row.description</td>
    </tr>
    }
    </tbody>
</table>

This is my output in the webpage:

Recent Posts
System.Byte[]   testaspform     ufegewu
System.Byte[]   testone     qfeyqo
System.Byte[]   testtwo     oadiufh

As you could see the first column show System.Byte[] instead of the image.

Related posts

Recent Viewed