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. how to save a file into MS Access Table...

how to save a file into MS Access Table...

Scheduled Pinned Locked Moved Visual Basic
databasecomdata-structureshelptutorial
8 Posts 3 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.
  • N Offline
    N Offline
    Nouvand
    wrote on last edited by
    #1

    hi.. everybody.. hope you can help me with this thing. Do you have any idea, how to save a file into MS Access database using VB 2005? Here's the simple scheme of the table FieldName {Data Type} -------------------------- Date {Date} EmployeeID {Number/Integer} Attachment {OLE Object} -------------------------- I red the MSDN help, but still haven't any idea how to apply it into my case. Or should i make an array of bytes stream of the file and then store it into 'Attachment' field. But then how the to read and restore/create the file back? Thanks before..

    K S 2 Replies Last reply
    0
    • N Nouvand

      hi.. everybody.. hope you can help me with this thing. Do you have any idea, how to save a file into MS Access database using VB 2005? Here's the simple scheme of the table FieldName {Data Type} -------------------------- Date {Date} EmployeeID {Number/Integer} Attachment {OLE Object} -------------------------- I red the MSDN help, but still haven't any idea how to apply it into my case. Or should i make an array of bytes stream of the file and then store it into 'Attachment' field. But then how the to read and restore/create the file back? Thanks before..

      K Offline
      K Offline
      Kschuler
      wrote on last edited by
      #2

      I haven't done anything like this with access, but with another database I declared a column of type blob....which essentially IS an array of bytes. That way I could store any type of file (.pdf, .jpg, .gif,...) Perhaps searching for information using the keyword "blob" will help you. Sorry i couldn't be more helpful.

      N 1 Reply Last reply
      0
      • N Nouvand

        hi.. everybody.. hope you can help me with this thing. Do you have any idea, how to save a file into MS Access database using VB 2005? Here's the simple scheme of the table FieldName {Data Type} -------------------------- Date {Date} EmployeeID {Number/Integer} Attachment {OLE Object} -------------------------- I red the MSDN help, but still haven't any idea how to apply it into my case. Or should i make an array of bytes stream of the file and then store it into 'Attachment' field. But then how the to read and restore/create the file back? Thanks before..

        S Offline
        S Offline
        Stephen McGuire
        wrote on last edited by
        #3

        This is an image file? Do you want to embed them in the database or create a link to them? OLE Object fields can be set to embed or link to an image or other OLE file such as a Word document or Excel workbook. Embedding an image (especially GIF and JPEG) will cause the size of the database to grow far beyond the size of the image files you embed and may cause the database to run much slower. Part of the reason is that Access creates a bitmap (bmp) of the image for display information purposes. Also, If users are using Access forms, they will need additional software to view images other than bitmap (.bmp) or device independent bitmap (.dib) files on a standard Windows installation. If the OLE Object field in the database is set to 'Link' instead of 'Embed' then all you need to do is store the path to the file. Steve

        N 1 Reply Last reply
        0
        • K Kschuler

          I haven't done anything like this with access, but with another database I declared a column of type blob....which essentially IS an array of bytes. That way I could store any type of file (.pdf, .jpg, .gif,...) Perhaps searching for information using the keyword "blob" will help you. Sorry i couldn't be more helpful.

          N Offline
          N Offline
          Nouvand
          wrote on last edited by
          #4

          Thanks anyway..:)

          1 Reply Last reply
          0
          • S Stephen McGuire

            This is an image file? Do you want to embed them in the database or create a link to them? OLE Object fields can be set to embed or link to an image or other OLE file such as a Word document or Excel workbook. Embedding an image (especially GIF and JPEG) will cause the size of the database to grow far beyond the size of the image files you embed and may cause the database to run much slower. Part of the reason is that Access creates a bitmap (bmp) of the image for display information purposes. Also, If users are using Access forms, they will need additional software to view images other than bitmap (.bmp) or device independent bitmap (.dib) files on a standard Windows installation. If the OLE Object field in the database is set to 'Link' instead of 'Embed' then all you need to do is store the path to the file. Steve

            N Offline
            N Offline
            Nouvand
            wrote on last edited by
            #5

            It will be pdf or ms office files. I want to embed it to the database. Here i tell you the concept we want to meet to: We have several teams on the field. And those team will use and report the data using that database. So for this purpose, i create the replica set. Frequently, they have to submit the pre-formated report in office(doc,xls,ppt) and pdf. The teams report once every month. So all they have to do is just to send the database file and at HQ team will syncronize the database and send it back to the field. I never use OLE object, so it possible to store array of byte into it? Is it take more space? ty:)

            N 1 Reply Last reply
            0
            • N Nouvand

              It will be pdf or ms office files. I want to embed it to the database. Here i tell you the concept we want to meet to: We have several teams on the field. And those team will use and report the data using that database. So for this purpose, i create the replica set. Frequently, they have to submit the pre-formated report in office(doc,xls,ppt) and pdf. The teams report once every month. So all they have to do is just to send the database file and at HQ team will syncronize the database and send it back to the field. I never use OLE object, so it possible to store array of byte into it? Is it take more space? ty:)

              N Offline
              N Offline
              Nouvand
              wrote on last edited by
              #6

              Wow... i just found it... Just take a line of code to read a file into an array of bytes, and a line for write the bytes array into a file... ty Microsoft ;P

              S 1 Reply Last reply
              0
              • N Nouvand

                Wow... i just found it... Just take a line of code to read a file into an array of bytes, and a line for write the bytes array into a file... ty Microsoft ;P

                S Offline
                S Offline
                Stephen McGuire
                wrote on last edited by
                #7

                If the column contains an array of bytes, I'm not sure Access will display the file. I think you would need code to extract the bytes to a file again. Also, you may want to try a few examples because, as I said, embedding files in Access (especially images) increases the file size by a huge amount. THis may not be the case with an array of bites... Steve

                N 1 Reply Last reply
                0
                • S Stephen McGuire

                  If the column contains an array of bytes, I'm not sure Access will display the file. I think you would need code to extract the bytes to a file again. Also, you may want to try a few examples because, as I said, embedding files in Access (especially images) increases the file size by a huge amount. THis may not be the case with an array of bites... Steve

                  N Offline
                  N Offline
                  Nouvand
                  wrote on last edited by
                  #8

                  I use ReadAllBytes and WriteAllBytes built-in functions Form Systems.IO namespace. The size is ok. :)

                  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