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. Recreating file system which contain data files

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

3. Writing Binary data to file

4. MFC ADO Access 2000 field containing file contents ?

5. Exclusive Unix file system file write locks and Oracle and Veritas

6. Storing binary file data in a Jet memo field

7. Writing long raw data to server file system

8. I want write field data in export file..

9. GetChunk fails when writing data from memo field to file

10. c:\program files\common files\system\ado

11. use of ADO to query file system (directories and files)

12. c:\program files\common files\system\ado is empty


 
Powered by phpBB® Forum Software