Dear all
I have a varbinary(max) column in sql server database table and i am fetching this data..I am inserting image in this column
How can display image in image control or in any other way
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Krishna GaradRank #191 · 12.8K reputationPosted Jan 6, 2012, 3:32 AM EST
public class ImageHandle : IHttpHandler {
public void ProcessRequest (HttpContext context) {
string imageid = context.Request.QueryString["ImID"];
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlcn"].ConnectionString);
connection.Open();
SqlCommand command = new SqlCommand("Select ImageColumn From TblImages Where ImageId="+imageid, connection);
SqlDataReader dr = command.ExecuteReader();
if (dr.Read())
{
context.Response.BinaryWrite((Byte[])dr[0]);
//context.Response.BinaryWrite((Byte[])dr[1]);
}
connection.Close();
context.Response.End();
}
public bool IsReusable {
get {
return false;
}
}
}
and in aspx page provide Image controls imageurl property like
Image1.ImageUrl="~/ImageHandle.ashx?ImID="+someid;
Mayur GujrathiRank #666 · 3.6K reputationPosted Jan 6, 2012, 8:20 PM EST
As per my question your answer is correct but i want to do slight change in this..
When i am fetching image i dont to display iy directly..
what ever no of images i am getting i want to create as much of link button dynamically and on click of i want to generate pop up to display paricular image..
Please help
Krishna GaradRank #191 · 12.8K reputationPosted Jan 6, 2012, 8:24 PM EST