i want to display image in Image control from database.
datatype is varbinary(max) .
<asp:Image ID="Image1" runat="server" CssClass=" img-rounded img-responsive" Style="width:300px;height:300px;margin-top:20px"/>
below is c# code
SqlConnection connection = new SqlConnection(connstring);
string sql = "select p.pro_id,p.pro_name,CONVERT(varchar,p.pro_posted_date, 103) as Date,p.pro_price,p.pro_image,a.ad_email,a.ad_phone from tbl_product_items p inner join tbl_admin a on a.ad_id=p.pro_fk_ad where pro_status='1' and p.pro_id= " + Request.QueryString["view"].ToString();
try
{
connection.Open();
SqlCommand cmd = new SqlCommand(sql, connection);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Label1.Text = reader.GetValue(1).ToString();
Label2.Text = reader.GetValue(2).ToString();
Label3.Text = reader.GetValue(3).ToString();
Image1.ImageUrl = reader.GetValue(4).ToString();
Label4.Text = reader.GetValue(5).ToString();
Label5.Text = reader.GetValue(6).ToString();
Label6.Text = reader.GetValue(0).ToString();
}
connection.Close();
}
catch (Exception ex)
{
Response.Write("Alert('error')");
}
Response.Write("Alert('error')");