You need to convert the data to a Byte Array before giving assigning it to a
memory stream.
Here's more info:
http://SteveOrr.net/articles/EasyUploads.aspx
http://SteveOrr.net/articles/ImproveYourImages.aspx
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Neo Geshel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I still have a problem displaying images from an access DB using asp.net.
>This showimage.aspx is for an admin site.
>
> I need to pull the correct image from the correct table, hence the two GET
> variables
>
> I need to re-size the image, while keeping the proper proportions, on the
> fly (before it gets to the browser). The images in the DB need to be full
> size for the actual web site; thumbnails are only needed in the admin
> site, hence the two functions that are included.
>
> Right now I am receiving an error:
> Exception Details: System.InvalidCastException: Specified cast is not
> valid.
>
> Source Error:
>
> myDataReader.Read()
> -> Dim imgStream As System.IO.MemoryStream = myDataReader.Item("Image")
> Dim imgbin() As Byte
> imgbin = createThumbnail(imgStream, 100, 100)
> Response.ContentType="image/jpeg"
> Response.BinaryWrite(imgbin)
>
> Problem is, when I set imgStream to:
>
> Dim imgStream As Byte = DirectCast(myDataReader.Item("Image"),Byte)
>
> I get the following error:
>
> Compiler Error Message: BC30311: Value of type 'Byte' cannot be converted
> to 'System.IO.Stream'.
>
> Source Error:
>
> myDataReader.Read()
> Dim imgStream As Byte = DirectCast(myDataReader.Item("Image"),Byte)
> Dim imgbin() As Byte
> -> imgbin = createThumbnail(imgStream, 100, 100)
> Response.ContentType="image/jpeg"
> Response.BinaryWrite(imgbin)
>
>
> HEEEEELP!!! What could I possibly do to make this work???
>
> TIA
> ...Geshel
> --
> **********************************************************************
> My reply-to is an automatically monitored spam honeypot. Do not use it
> unless you want to be blacklisted by SpamCop. Please reply to my first
> name at my last name dot org.
> **********************************************************************