Write ADO Field containing binary data (files) to the file system 
Author Message
 Write ADO Field containing binary data (files) to the file system

Hi,
I inherited a SQL Server database with file attachments (PDF, Zip,
Word etc.) stored in an Image field.  I want to write the file
attachments out to a directory on the file system.  I reviewed
Microsoft's article Q258038:
"HOWTO: Access and Modify SQL Server BLOB Data by Using the ADO Stream
Object"
but this only seemed to work with Microsoft files (e.g. Word, Excel,
BMP).  Others (e.g. PDF, Zip) indicated that "the application could
not open the file because it is not a supported file type or it is
corrupted".  Does anyone have any other suggestions?  Thanks in
advance.
Cheers,
Julian


Wed, 31 Aug 2005 10:35:12 GMT  
 Write ADO Field containing binary data (files) to the file system
Julian,

It is not only working with Microsoft files. When you save binary info into
image/binary field, SQL Server does not know if it is from the Microsoft or
not. I am pretty sure problem somewhere inside your code. What are you
tyring to achieve? Could you post your code here?

--
Val Mazur
Microsoft MVP


Quote:
> Hi,
> I inherited a SQL Server database with file attachments (PDF, Zip,
> Word etc.) stored in an Image field.  I want to write the file
> attachments out to a directory on the file system.  I reviewed
> Microsoft's article Q258038:
> "HOWTO: Access and Modify SQL Server BLOB Data by Using the ADO Stream
> Object"
> but this only seemed to work with Microsoft files (e.g. Word, Excel,
> BMP).  Others (e.g. PDF, Zip) indicated that "the application could
> not open the file because it is not a supported file type or it is
> corrupted".  Does anyone have any other suggestions?  Thanks in
> advance.
> Cheers,
> Julian



Fri, 02 Sep 2005 00:46:42 GMT  
 Write ADO Field containing binary data (files) to the file system
Hi,

Thanks for your reply.  Currently, the code is straight out of
Microsoft's Q258038, but I discovered that the database field is not
storing the original raw binary from the attachment.  Instead, the
attachment is loaded into an OLE Container Control and then saved to
the database, so the field must have OLE headers in it which is why I
see that it is corrupted.

What I really need to do then is populate an OLE Container Control
from an ADO field and then export the file from the OLE Container
control to the file system.  I don't think that I can use a bound
control because the ADO field is based on an underlying SQL Server
Database not Access or something that I could access with Jet.  I see
that in VB you can do an OLE1.Copy to copy the contents of the
container to the System clipboard.  However, that still leaves two
problems:
(1) Populating the OLEContainer from the ADO field.
(2) Pasting from the System clipboard to the filesystem.  Perhaps I
could launch Explorer then issue a SendKeys, but that seems pretty
flaky.

Any ideas would be great.
Thanks,
Julian



Sat, 03 Sep 2005 05:10:33 GMT  
 Write ADO Field containing binary data (files) to the file system
Julian,

Are you using SQL Server or Access database. In case of SQL Server there is
no OLE header and it exists only for OLE field in Access database. That
example from KB does not have anything related to OLE header and does not
use any OLE Container Control . Why do you say about OLE? It is not related
to your situation. Could you post your code, which load and reads BLOB data?

--
Val Mazur
Microsoft MVP


Quote:
> Hi,

> Thanks for your reply.  Currently, the code is straight out of
> Microsoft's Q258038, but I discovered that the database field is not
> storing the original raw binary from the attachment.  Instead, the
> attachment is loaded into an OLE Container Control and then saved to
> the database, so the field must have OLE headers in it which is why I
> see that it is corrupted.

> What I really need to do then is populate an OLE Container Control
> from an ADO field and then export the file from the OLE Container
> control to the file system.  I don't think that I can use a bound
> control because the ADO field is based on an underlying SQL Server
> Database not Access or something that I could access with Jet.  I see
> that in VB you can do an OLE1.Copy to copy the contents of the
> container to the System clipboard.  However, that still leaves two
> problems:
> (1) Populating the OLEContainer from the ADO field.
> (2) Pasting from the System clipboard to the filesystem.  Perhaps I
> could launch Explorer then issue a SendKeys, but that seems pretty
> flaky.

> Any ideas would be great.
> Thanks,
> Julian



Sat, 03 Sep 2005 20:35:13 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Write image data as binary to append existing file

2. Write data in binary file / Convert Image

3. Reading/Writing Data for Binary Files

4. How to write binary data into a file?

5. Writing binary data to file with VBScript?

6. writing binary data to a file

7. reading binary file and writing into a random access file

8. VB -- Long File Name , Fast Binary File Read / Write , interface with DLL

9. Saving DB binary field data into file

10. Storing binary file data in a Jet memo field

11. How to write a data arrary to a Long Binary field of Access97

12. How to read one file and write certain fields to another file

 

 
Powered by phpBB® Forum Software