Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Display OLE Object

Display OLE Object

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasecomdocker
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    scitro
    wrote on last edited by
    #1

    Dear All, I used OLe Container in VB6.0 to upload image to database. The image is saved in database as compounded file binary. Now I am using VB.NET to retrieve the file.. but somehow I could not extract the embedded file from that OLE Binary. Does someone have a workaround for this? Much Appreciated. Sandy

    C 1 Reply Last reply
    0
    • S scitro

      Dear All, I used OLe Container in VB6.0 to upload image to database. The image is saved in database as compounded file binary. Now I am using VB.NET to retrieve the file.. but somehow I could not extract the embedded file from that OLE Binary. Does someone have a workaround for this? Much Appreciated. Sandy

      C Offline
      C Offline
      Cliff Wellman
      wrote on last edited by
      #2

      This should work for you. I know that it works with MS-Access. Assuming you table contains the following fields IMAGE_ITEM_ID : Long NAME : Text IMAGE : OLE Object Public Sub GetItem(ByVal itemId As Long) Dim sqlQuery As String ' the query to execute Dim image() As Byte ' the image to get Dim name as String ' the name of the image sqlQuery = "SELECT IMAGE_ITEM_ID, NAME, IMAGE " & _ "FROM IMAGE_ITEM " &_ "WHERE IMAGE_ITEM_ID = " & itemId Try ' instanciate a connection object Dim conn As OleDb.OleDbConnection = GetConnection() ' instanciate a command object Dim com As New OleDbCommand(sqlQuery, conn) ' open the connection com.Connection.Open() ' create a read to read the database Dim reader As OleDbDataReader ' open the reader reader = com.ExecuteReader(CommandBehavior.CloseConnection) ' read the first record If (reader.Read()) Then ' get the name of the image name = reader.GetString(1) ' get the image itemData.Image = CType(reader.Item(2), Byte()) End If ' clean up after yourself reader.Close() com.Connection.Close() conn.Dispose() 'release memory to garbage collection com.Dispose() 'release memory to garbage collection Catch eOleDb As OleDb.OleDbException MsgBox("OleDb Error - GetItem - [" & eOleDb.Message & "]") End Try End Sub I hope it works for you.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups