Displaying images
<p>My instructor gave us example code that is very similiar to the code below. I haven't heard back from him yet and wanted to find out why my code won't work properly. Could someone give me some advice on what I'm doing wrong or an easier method to display images. Thanks for your time.</p>

<pre><code>&lt;%@ WebHandler Language="VB" Class="images" %&gt;

Imports System
Imports System.Web
Imports System.Data.SqlClient
Public Class images : Implements IHttpHandler

    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest


        Dim id As String = context.Request.QueryString("ImageId")
        Dim userId As Integer = 4


        Dim conn As New System.Data.SqlClient.SqlConnection


        Dim cmd As New System.Data.SqlClient.SqlCommand


        conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
        cmd.Connection = conn
        cmd.CommandText = "SELECT Image FROM mrg_Image WHERE UserId=@userId"
        cmd.Parameters.AddWithValue("@userId", userId)

        conn.Open()
        Dim file_bytes As Byte() = cmd.ExecuteScalar()        
        Dim file_bytes_stream As New System.IO.MemoryStream(file_bytes)

        'During the build - The next line of code is highlighted green with the error message of, "Parameter is invalid"

        Dim the_image As New System.Drawing.Bitmap(file_bytes_stream)

        context.Response.ContentType = "image/jpg"
        the_image.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)        

        conn.Close()
    End Sub

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

End Class
</code></pre>
