Display DB2 BLOB Image on Web Page

We are storing images in a DB2 database and would like to display them on the web page.

How do you do it?



Same way as with any other bag o bytes:

  1. Make IHttpHandler capable of loading bytes and mimetype from db.
  2. Have page call IHttpHandler with appropriate parameters.

I’m not sure how to do that, but I have more information for you.
I figure that I will need to import the IHttpHandler. Is that correct? If so; what is the import? I could not find it.

After that, what code do I write to display the BLOB as an image?

I have code from a co-worker which returns one image. Thought it would at least return one after another.

I would like to be able to just attach the image(BLOB to a gridview or datagrid) as well as use the images to populate dynamically based on referencing the id. Any thoughts?

Here is the code we are using:

Partial Class Images
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim dv As Data.DataView = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), Data.DataView)

        For Each dr As Data.DataRow In dv.Table.Rows

            Response.ContentType = "image/png"
            Response.BinaryWrite(CType(dr(1), Byte()))


    End Sub
End Class