asp.net storing images
<p>It's me your junior programmer extraodinaire</p>

<p>I'm trying to display an image from my database but when I try to extract the file it only contains 6 bytes of data which causes my program to throw an error. My instructor informed me that the file is too small for an image, leading me to believe that I'm not storing it properly. I would be most gracious if someone could identify any code that might cause this to happen. </p>

<p>this is my function grabbing/storing the file</p>

<pre><code>Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
    Dim _image As Byte()
    _image = FileUpload1.FileBytes
    Dim conn As New SqlConnection
    Dim cmd As New SqlCommand

    Dim dr As SqlDataReader

    conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
    cmd.Connection = conn
    cmd.CommandText = "Insert INTO mrg_Image(Image, UserId) VALUES('@image', @id)"

    cmd.Parameters.AddWithValue("@image", FileUpload1.FileBytes)
    cmd.Parameters.AddWithValue("@id", 4)


    conn.Open()
    dr = cmd.ExecuteReader
    conn.Close()

    'FileUpload1.SaveAs()

End Sub



    conn.Open()
</code></pre>

<p>file_bytes is the variable that contains 6 bytes as oppose to a thousand+ which an image should have</p>

<pre><code>    Dim file_bytes As Byte() = cmd.ExecuteScalar()        
    Dim file_bytes_memory_stream As New System.IO.MemoryStream(file_bytes)
    Dim file_bytes_stream As System.IO.Stream = DirectCast(file_bytes_memory_stream, System.IO.Stream)

    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
</code></pre>
