Blob sub_type 1 is Text. sub_type 0 is binary. That is why you are getting
a string from the database.
see http://www.firebirdfaq.org/faq165/

On Fri, Nov 2, 2012 at 2:32 PM, Mr. John <mr_joh...@yahoo.com> wrote:

> Hi !
>  I'm using VB.2008 with FB 2.5/,Net provider version 2.7.7.0
>
> I want  to save and retrieve/bind image from/to picture box control
>
> image database field :
>  F_IMAG      BLOB SUB_TYPE 1 SEGMENT SIZE 4096
>
> saving to database :
> ....
>  Dim IMG As New Bitmap(PictureBox1.Image)
>                 Dim stream As New IO.MemoryStream
>                 IMG.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg)
>                 .Add("@pimg", FbDbType.Binary).Value = stream.ToArray()
> ....
>  no error here
>
> but I got this error :
>   Unable to cast object of type 'System.String' to type 'System.Byte[]'.
> when I try to retrieving/binding image with this code :
>
>   Dim WithEvents bind As Binding
> .....
>         bind = New Binding("Image", bSource_, "F_IMAG")
>         Me.PictureBox1.DataBindings.Add(bind)
>
> .....
>
>     Private Sub Binding_Format(ByVal sender As System.Object, ByVal e As
> ConvertEventArgs) Handles bind.Format
>         Dim img As Byte()
>         img = CType(e.Value, Byte())   'Unable to cast object of type
> 'System.String' to type 'System.Byte[]'.
>
>         If (Not img Is Nothing) Then
>             e.Value = Image.FromStream(New System.IO.MemoryStream(img))
>         End If
>     End Sub
>
>
> thanks for any help !
>
>
>
> ------------------------------------------------------------------------------
> LogMeIn Central: Instant, anywhere, Remote PC access and management.
> Stay in control, update software, and manage PCs from one command center
> Diagnose problems and improve visibility into emerging IT issues
> Automate, monitor and manage. Do more in less time with Central
> http://p.sf.net/sfu/logmein12331_d2d
> _______________________________________________
> Firebird-net-provider mailing list
> Firebird-net-provider@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
>
>
------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to