Hello.
I am attempting to write binary data from a file to an
OLE Object field, and then write the file back out from
the database. I am reading and writing the files in
binary mode, and using GetChunk and AppendChunk to read
and write binary data from the OLE Object field. I am
using VBA and DAO for this experiment. The OLE Object
field is being used to store Long Binary data.
I have tried four variations as follows:
1. a. Read file data into a byte array
b. AppendChunk byte array to DAO field
c. GetChunk DAO field data into byte array
d. Write byte array to file
This SHOULD be the correct method, but it doesn't
work. I don't know why. The output file is the same
size as the input file. The first half of the output
file matches the first half of the input file.
The second half of the output file is garbage.
2. a. Read file data into a string variable
b. AppendChunk string variable to DAO field
c. GetChunk DAO field data into string variable
d. Write string variable to file
With this approach, the output file is half the
size of the input file. The output file matches the
first half of the input file.
Obviously, the devil here is that VB stores string
data internally as double-byte characters. With
this in mind, I can actually get this approach
to work if I calculate the chunk size based on a
doubled input file size. But this doubles the storage
size in the database, since the data is saved as
double-byte characters.
The other two methods mixed the string and byte
array methods (read string/write byte array,
read byte array/write string). Neither worked.
Suggestions?
Thanks
-Mark