get image data from dataset (insead of directly from db)

  • Thread starter Thread starter MattB
  • Start date Start date
M

MattB

I have a slightly different twist on the old question "How do I display
images stored in my database?".

My application does not talk directly to the database. It uses a COM+ dll to
deliver serialized datasets. Then I de-serialize those datasets and work
from those.

All the examples I've seen use a SQL adaptor to stream the data and I can't
quite make that work directly from a dataset. I've tried the following code
but I get a "Specified cast is invalid" when I try to assign a byte array
variable the value from the dataset field (which I see in the debugger is of
a type 'bin.hex'). I also can't seem to get convert.tobyte to work (probably
since it's a byte array). Anyone got any hints for me? Seems like I'm
close, but no cigar.

Dim oRow As DataRow

oRow = oDs.Tables(1).Rows(0)

Dim MyData() As Byte

MyData = oRow.Item("mug_shot") 'this is where I hit the casting error

Response.Buffer = True

Response.ContentType = "Image/JPEG"

Response.BinaryWrite(MyData)


If it matters, these are jpeg images stored as type images in sql server,
but are delivered as strings (serialized datasets). Thanks!

Matt
 
Thanks, I think you are correct, but I still have the problem of the data
being in 'bin.hex'.
Any suggestions or examples for converting the image data from 'bin.hex' to
a bit array?

Matt
 
Back
Top