Picture box binding problem
-
I'm trying to bind a picture box to my access 2003 Db in vb.net Here is my code
Dim b As Binding = New Binding("Image", dsComics, "comiclist.ComicCover") AddHandler b.Format, AddressOf ConvertPicture Me.picCover.DataBindings.Add(b) Public Sub ConvertPicture(ByVal Sender As Object, ByVal e As ConvertEventArgs) Dim b() As Byte = e.Value Dim ms As MemoryStream = New MemoryStream ms.Write(b, 0, b.Length) **Dim bmp As Bitmap = New Bitmap(ms)** ms.Close() e.Value = bmp End Sub
The line in bold is where it bombs, any ideas BINARY -
I'm trying to bind a picture box to my access 2003 Db in vb.net Here is my code
Dim b As Binding = New Binding("Image", dsComics, "comiclist.ComicCover") AddHandler b.Format, AddressOf ConvertPicture Me.picCover.DataBindings.Add(b) Public Sub ConvertPicture(ByVal Sender As Object, ByVal e As ConvertEventArgs) Dim b() As Byte = e.Value Dim ms As MemoryStream = New MemoryStream ms.Write(b, 0, b.Length) **Dim bmp As Bitmap = New Bitmap(ms)** ms.Close() e.Value = bmp End Sub
The line in bold is where it bombs, any ideas BINARY'use to save image file Dim arr() As Byte FileOpen(1,"FilePath" , OpenMode.Binary, OpenAccess.Read, OpenShare.Shared) 'Resize array so that it can accomodate the file ReDim arr(FileLen("FilePath") - 1) FileGet(1, arr) FileClose(1) 'use to read image file arr = ds.Tables("TableName").Rows(0).Item("ColumnName") 'comapny logo is the name of PictureBox control CompanyLogo.Image = CompanyLogo.Image.FromStream(New IO.MemoryStream(arr))
-
'use to save image file Dim arr() As Byte FileOpen(1,"FilePath" , OpenMode.Binary, OpenAccess.Read, OpenShare.Shared) 'Resize array so that it can accomodate the file ReDim arr(FileLen("FilePath") - 1) FileGet(1, arr) FileClose(1) 'use to read image file arr = ds.Tables("TableName").Rows(0).Item("ColumnName") 'comapny logo is the name of PictureBox control CompanyLogo.Image = CompanyLogo.Image.FromStream(New IO.MemoryStream(arr))
-
I tried that and it bombed here: picCover.Image = picCover.Image.FromStream(New IO.MemoryStream(arr)) might it be a problem with access?
use Dataset to retrieve and save image I am using following lines .there is no error arr = ds.Tables("CompanyInfo").Rows(0).Item("CompanyLogo") CompanyLogo.Image = CompanyLogo.Image.FromStream(New IO.MemoryStream(arr)) there is also an article with demo project(using access) is available in this group. try to search with keyword "Image"
-
use Dataset to retrieve and save image I am using following lines .there is no error arr = ds.Tables("CompanyInfo").Rows(0).Item("CompanyLogo") CompanyLogo.Image = CompanyLogo.Image.FromStream(New IO.MemoryStream(arr)) there is also an article with demo project(using access) is available in this group. try to search with keyword "Image"
ok I'll try it thanx BINARY
-
ok I'll try it thanx BINARY
nope nothing, If any one could build a sample to show me where I'm going wrong. I've heard something about header information in the field. BINARY