Question Getting Image from OLE Object into PictureBox

mmgrote

New member
Joined
May 10, 2012
Messages
1
Programming Experience
3-5
I am programming with Access 2007
VB.net in Visual Studio 2010

I am trying to have my VB program read the database, extract the .bmp image, and assign it to a PictureBox on the fly (I am actually creating a Group on the fly and filling it with data from the database that are selected by my query. One of the fields is "image". All of my other fields are successfully transferring from the DB to the group box.) My problem is converting the OLE Object to a picture/image that I can assign to the PictureBox.

I am using TableAdapters and queries set up in an .xsd.

I have a database with an OLE Object field.

Here is a code snipit of my database set up:

Dim ta AsNew dsWhiteboardTableAdapters.MonstersTableAdapter
Dim monsterList AsNewdsWhiteboard.MonstersDataTable
Dim monster AsdsWhiteboard.MonstersRow
Dim newMonster AsGroupBox

ta.Fill(monsterList)

Dim cnt AsInteger = monsterList.Rows.Count

If cnt > 0 Then

For r AsInteger = 0 To cnt - 1
monster = CType(monsterList.Rows(r), dsWhiteboard.MonstersRow)
newMonster = NewGroupBox

newMonster.Text = monster.condition
newMonster.Tag = monster.ID
newMonster.Size = NewSize(grpWidth, grpHeight)
newMonster.Location = NewPoint(xCoord, yCoord(grpCounter))
newMonster.BackColor = Color.FromKnownColor(KnownColor.Control)
'newCharacter.Font = New Font("Microsoft Sans Serif", 8)
newMonster.Font = NewFont("Microsoft Sans Serif", 12, FontStyle.Bold)
newMonster.ForeColor = Color.DarkRed

'Add Image to group for Pic
newPic = NewPictureBox
newPic.Location = NewPoint(72, 5)
newPic.Size = NewSize(54, 54)
Participants.Add(newMonster)
grpCounter += 1
Next


I have tried several ways of getting the image into my picturebox, all lead to errors. I also searched forums for solutions and none seemed to work in my scenario.

If you need additional code, i would be glad to provide.
Any suggestions?
 
Here is one option that should work for most, if not all, databases:

Saving Images in Databases

The thing is, in the case of Access, I think that that will work if you save the image that way in the first place but not if you have added the image inside the Access application. Is that an issue?
 
Back
Top