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. C#
  4. Extracting OLE Object from MS Access

Extracting OLE Object from MS Access

Scheduled Pinned Locked Moved C#
csharpquestiondatabasecom
6 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.
  • A Offline
    A Offline
    AngryC
    wrote on last edited by
    #1

    Hello, I'm using MS Access as database back-end for my C# application and I have an OLE Object field in my MS Access Database and I want to extract the content (say JPG image) to the users' desktop. I'm using OleDB and C#.NET 2.0. How can I do that? Thanks.

    N 1 Reply Last reply
    0
    • A AngryC

      Hello, I'm using MS Access as database back-end for my C# application and I have an OLE Object field in my MS Access Database and I want to extract the content (say JPG image) to the users' desktop. I'm using OleDB and C#.NET 2.0. How can I do that? Thanks.

      N Offline
      N Offline
      Nader Elshehabi
      wrote on last edited by
      #2

      Hello O'm not sure if this would work or not, but read it as binary in a stream, and build an image object from that stream.

      Regards:rose:

      A 1 Reply Last reply
      0
      • N Nader Elshehabi

        Hello O'm not sure if this would work or not, but read it as binary in a stream, and build an image object from that stream.

        Regards:rose:

        A Offline
        A Offline
        AngryC
        wrote on last edited by
        #3

        Thanks Nader it almost worked but I'm no getting a text file extracted well... the first line is: $      ےےےےPackage Package    Package ²{  Sa.txt C:\DOCUME~1\Owner.Joe\Desktop\SA.txt  $ C:\DOCUME~1\Owner.Joe\Desktop\SA.txt S{ ... Then the content of my file begins! The same for the last line:   METAFILEPICT " »ْےےî  "E  s      2 '  ûُے گ  Tahoma è vـٍ ¸¤َwء¤َw 0ُw‘"f  -    ےےے    . ! Sa.txt!   û  ¼ ²"System ‘"f & ٹ ےےےےhَ  -  L­‏ What's worng? Thanks.

        N 1 Reply Last reply
        0
        • A AngryC

          Thanks Nader it almost worked but I'm no getting a text file extracted well... the first line is: $      ےےےےPackage Package    Package ²{  Sa.txt C:\DOCUME~1\Owner.Joe\Desktop\SA.txt  $ C:\DOCUME~1\Owner.Joe\Desktop\SA.txt S{ ... Then the content of my file begins! The same for the last line:   METAFILEPICT " »ْےےî  "E  s      2 '  ûُے گ  Tahoma è vـٍ ¸¤َwء¤َw 0ُw‘"f  -    ےےے    . ! Sa.txt!   û  ¼ ²"System ‘"f & ٹ ےےےےhَ  -  L­‏ What's worng? Thanks.

          N Offline
          N Offline
          Nader Elshehabi
          wrote on last edited by
          #4

          Textfile?? You didn't mention text? I thought you said that you are reading an image from the database, so you should read it as binary stream then on the fly call Image.FromStream() method. Why did you create a text file for the image? What you got is binary, and it won't be displayed properly by any text editor -eg. notepad-. If I'm getting you wrong or missing something, please clarify.

          Regards:rose:

          A 1 Reply Last reply
          0
          • N Nader Elshehabi

            Textfile?? You didn't mention text? I thought you said that you are reading an image from the database, so you should read it as binary stream then on the fly call Image.FromStream() method. Why did you create a text file for the image? What you got is binary, and it won't be displayed properly by any text editor -eg. notepad-. If I'm getting you wrong or missing something, please clarify.

            Regards:rose:

            A Offline
            A Offline
            AngryC
            wrote on last edited by
            #5

            I thought it's the same thing so I said image just to make it simple :-O Ok so now I have an access db and I'm inserting an html document into an OLE field by right clicking and choosing insert object... How can I - by code - extract the exact html file and save it to the user desktop?

            N 1 Reply Last reply
            0
            • A AngryC

              I thought it's the same thing so I said image just to make it simple :-O Ok so now I have an access db and I'm inserting an html document into an OLE field by right clicking and choosing insert object... How can I - by code - extract the exact html file and save it to the user desktop?

              N Offline
              N Offline
              Nader Elshehabi
              wrote on last edited by
              #6

              Well, please don't be offended, I was just wondering. To some extent yes, it could be almost the same. For the Html document you are storing -though I'd prefer to store it in the Db as text. This would be much easier-, the Html text itself won't be changed, but you wil find some binary OLE Metadata at the begining of the doument. You just got to ignore it in your Stream, and begin reading from the first Html tag -eg. <html>, or <body>, etc..-. That should do it, but then you have to treat it like text and not binary like storing it in a string and saving it to html file. Also the images of the html page won't be saved in the Db, and when you extract the file and save it to "something.html" you will only get the html and no pictures -except of course if they are online pictures, and you were connected-. I hope I was close enough this time. -- modified at 22:29 Sunday 15th October, 2006 Oh! I almost forgot. About the metadata at the end, just ignore whatever is after the </html> tag. BTW: How do you extract the Oleobject from you Db in C# code?

              Regards:rose:

              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