I want to save and开发者_StackOverflow社区 retrieve the image from local database. I insert image as blob in db but I am usable to retrieve image.
Please help me.
Thanks Monali
What error are you getting? Using LINQ to SQL, the following code creates an HttpHandler and grabs a BLOB from a database...
public class GetFile : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
Document document = new GigzDataContext().Documents.SingleOrDefault(p => p.Id == new Guid(context.Request.QueryString["Id"].ToString()));
context.Response.ContentType = document.ContentType;
context.Response.BinaryWrite(document.Blob.ToArray());
}
public bool IsReusable
{
get
{
return false;
}
}
}
See this link to have a concept on how to retrieve blob data from a database table as bytes, and after you have them in bytes, you should be able to save them into proper format to form your final image.
精彩评论