Reputation: 351
I have a column in my table stored in MS Access as a Attachment
data type. It stores various files such as docx, pdf's etc.
I am trying to display a file from the table using a documentViewer (obtained from XtremeDocumentStudio .NET
).
I also have a combo box on my form with a list of employee ID's. When a particular ID is selected from the combo box, I want the associated attachment with that employee to be displayed in the documentViewer.
I am using this query:
SELECT EmployeeAttachment FROM Employee WHERE EmployeeID = 2
I have been stuck on this problem for a while and am not sure on how to implement it. Any help or ideas on how I would do this would be greatly appreciated.
Upvotes: 1
Views: 1935
Reputation: 123829
In order to get a faithful copy of the file from the Attachment field in the Access database you need to use the .SaveToFile
method of an ACE DAO Field2
object. For details, see the related question:
Extracting files from an Attachment field in an Access database
Once you have extracted the file to disk (e.g., to System.IO.Path.GetTempPath
) then you can tell the viewer control where to find it.
Upvotes: 1