2011-06-06 176 views

回答

0

你有什麼錯誤?使用LINQ to SQL,以下代碼創建HttpHandler並從數據庫中獲取BLOB ...

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; 
     } 
    } 
} 
0

this link有關於如何從一個數據庫表中的字節檢索BLOB數據的概念,你以字節爲單位有他們之後,你應該能夠把它們保存到正確的格式形成你的最終形象。

相關問題