nothing else

nothing else

  • NA
  • 28
  • 32.1k

Response.BinaryWrite error by LINQ

Mar 2 2013 12:20 PM
I have used the ADO.NET which i don't want to use to save Image to Database, but when i use LINQ to save image, i'm get error.

here is my DB:


ImageHandler.ashx
public class ImageHandler : IHttpHandler {

ImageDataDataContext image = new ImageDataDataContext();

  public void ProcessRequest (HttpContext context) {

        string imageid = context.Request.QueryString["ImID"];
        var ketqua = (from img in image.tblImgs
                      where img.imgID == int.Parse(imageid)
                      select new
                      {
                          img.imgData
                      }).First();
        context.Response.BinaryWrite((byte[])ketqua); //Cannot convert type 'AnonymousType#1' to 'byte[]'        context.Response.End();
}

public bool IsReusable {
  get {
  return false;
  }
}

}

Can you pls help me how to correct the error. thanks :)

Answers (5)