Imports System.Web
Imports System.Web.Services
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.IO

Public Class showEventLogo
    Implements System.Web.IHttpHandler

    Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        Dim Conn As SqlConnection = New SqlConnection
        Conn.ConnectionString = ConfigurationManager.ConnectionStrings("CalendarConnStr").ConnectionString
        Conn.Open()
        Dim sql As String = "Select event_graphics from event_logo where event_logo_id=@ImageId"

        Dim cmd As New SqlCommand(sql, Conn)
        cmd.Parameters.Add("@ImageId", SqlDbType.Int).Value = context.Request.QueryString("id")
        cmd.Prepare()
        Dim dr As SqlDataReader
        dr = cmd.ExecuteReader()

        dr.Read()
        Dim arrContent As Byte()
        arrContent = CType(dr("event_graphics"), Byte())

        context.Response.ContentType = "image/*"
        context.Response.BinaryWrite(arrContent)
    End Sub

    ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

End Class