Save a Word Doc in Access Databasse

Joined
Sep 3, 2008
Messages
19
Programming Experience
1-3
Assume I have a table which has the following fields: 1) Document Name 2) File Name 3) File Content

The File Content field is defined as an OLE data type. This is the field I want to use for saving Word documents.

How can I use a dataset to save a word document in the File Content field? Please provide code.
How can I retrieve this document from the File Content field using a dataset and save it to disk? Please provide code?

Thanks.
 
It's no different to saving any other data to a database, so I'm not going to provide code. The data type is Byte(), i.e. Byte array, so you just need to get a Byte array containing the data of the file and put that into the appropriate field of your DataRow, the same way you would text, numbers or any other data.

As for getting that array in the first place, the IO.File.ReadAllBytes method will read the binary contents of a file and return it in a Byte array. The IO.File.WriteAllBytes method will do the opposite, i.e. write a Byte array to a file.
 
Back
Top