Re: Load image from DB into PictureBox control

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Jim,

When I try the CType conversion I get the following error in my Task list:

Value of type '1-dimensional array of Byte' cannot be converted to 'Byte'.

I know it can be done. I've seen sample Northwind applications that have
done it but that was a long time ago and I never needed to know. Now I
don't remember what those applications were.

Any other ideas?

Thanks again,

King

"Jim Hughes" wrote:

> ba = CType( .Photo, Byte() )
>
> "K. Wilder" <KWilder@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:060EBEB6-0BDE-4B68-AE26-D6FDAD94ED99@xxxxxxxxxxxxxxxx
> > Tim,
> >
> > I tried your Google example and got an "Invalid parameter used" error.
> >
> > This is my code:
> >
> > Dim ba() as Byte
> > ba = .Photo
> > Dim ms As New IO.MemoryStream(ba)
> > Me.picBox.Image = Image.FromStream(ms)
> >
> > Any ideas?
> >
> > Thanks,
> >
> > King Wilder
> >
> >
> > "Tim Wilson" wrote:
> >
> >> If the image is in a Byte array then you could create a MemoryStream
> >> using
> >> this Byte array, then call the shared FromStream method of the Image
> >> class
> >> passing in the MemoryStream. There's some sample code at the link below.
> >>
> >> http://www.google.ca/groups?hl=en&lr=&selm=erQHZobLEHA.2388%40TK2MSFTNGP09.phx.gbl
> >>
> >> --
> >> Tim Wilson
> >> ..Net Compact Framework MVP
> >>
> >> "K. Wilder" <KWilder@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> >> news:36DBE9AA-58C0-4FFB-8D22-45F985F49C23@xxxxxxxxxxxxxxxx
> >> > In VB.Net, does anyone know how to load an image from, example
> >> > Northwind
> >> DB
> >> > employees table, to a picture box control?
> >> >
> >> > The Image is in Byte format and I can't figure out how to convert it to
> >> > an
> >> > image.
> >> >
> >> > Thanks,
> >> >
> >> > King Wilder
> >>
> >>
> >>
>
>
>
.



Relevant Pages

  • Re: Zip file using a stream
    ... I am focused at figuring out why the zip file is corrupt in cases #1 ... // This method outputs a zip file to a memorystream ... // The input in all three test cases is a byte array from different ... write additional junk to the ZipOutputStream at the end might corrupt ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Craete tiff Image Page by Page
    ... the tiff image from a dll other than "Memory buffer" ... To load a Tiff into a memoryStream, ... use a Filestream to read it into a byte array, ... EncoderParameter(Encoder.Compression, imgCompression); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Issues with input
    ... I have a webpage explaining all of this, with sample code, here: ... > Intitialise all elements of history to NULL. ... the array ...
    (comp.lang.c)
  • RE: Craete tiff Image Page by Page
    ... This sample methods accepts an array of your individual loaded Tiff "pages" ... To load a Tiff into a memoryStream, ... use a Filestream to read it into a byte array, ... EncoderParameter(Encoder.Compression, imgCompression); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to pass an array of single values to a message?
    ... The OleControl prompt "data is not the correct type". ... I suspect the error is caused by the data type in the array. ... The vendor of the ActiveX control has some sample of using the control. ... However these sample code is in VB and Visual C++. ...
    (microsoft.public.fox.programmer.exchange)