Results 1 to 12 of 12

Thread: Retrieving & Viewing Attachments from Access 2007 or Later ACCDB Files

Threaded View

  1. #1

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Retrieving & Viewing Attachments from Access 2007 or Later ACCDB Files

    I've seen quite a few people asking how to view data from a column of data type Attachment in an Access 2007, 2010 or 2013 database. The answer is that it's not straightforward at all, but it is possible. There are a few suggestions out there but I wanted to provide a purely ADO.NET solution. With a bit of help from some existing posts out there and a bit of messing around, I've come up with the solution attached to this post, which was created in VB 2010.

    If you open the ACCDB file that is included in the project, you can see the schema and data for the Record table. When you run the project you will see ID and Description columns in the upper grid corresponding to the rows in that Record table. When you select a record, the lower grid will be populated with the attachments for that record. Click on the Open button for an attachment and it will open as though you had double-clicked it in Windows Explorer.

    Note that the data for an attachment is saved to a file in the Temp folder when you open it. The app attempts to clean up any such files when it closes but, if the file is not closed before you close the app or you stop debugging in VS instead of closing the form, the temp file will not be deleted.

    If you have any questions, please make absolutely sure that you have read the code and the comments thoroughly before posting it here. If you ask a question that is already answered in the aforementioned code or comments then none at all will be the best response you will get and may not be the worst. Also, this project can be opened in VS 2010 or 2012 and VB 2010 Express or VS Express 2012 for Windows Desktop. I will be creating a C# version but I will not be redoing the project for any older versions of VB. If that's all you have then you can either just read the code file or just install a newer version, which can be done without affecting your current version.

    Note that I am hoping to be able to enhance this sample to allow saving of attachments too but that will take a bit more research and testing. I know what some of the header data on the file contents is but not all at this stage. Also, I'd like to acknowledge the following two posts in helping me to create this sample:

    http://social.msdn.microsoft.com/For...6-ebb44a70fef8
    http://social.msdn.microsoft.com/For...F-8B8A26D54B85
    Attached Files Attached Files
    Last edited by jmcilhinney; Nov 15th, 2012 at 04:18 AM. Reason: Updated attachment
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Click Here to Expand Forum to Full Width