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

Public Class showSponsorLogo
    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 sponsor_graphics from event_sponsors_logo where sponsors_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("sponsor_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