Results 1 to 2 of 2

Thread: Getting Image from OLE Object into PictureBox

  1. #1
    mmgrote is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    May 2012
    Posts
    1
    Reputation
    0

    Getting Image from OLE Object into PictureBox

    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?

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is online now VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,342
    Reputation
    1543
    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?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking