How to read and write a word-document from a database

  • Thread starter Thread starter Henke
  • Start date Start date
H

Henke

Hi
I'd like to stream a word document to a sql server database and then read it
back to a file again.
How can this be done?

Thanks!

/Henke
 
Yes, but it's a lot of trouble. You have to create a BLOB (IMAGE) column for
the data and follow specific rules to get ADO.NET to write it to the
database. Once there, it is handled fairly efficiently, but when you fetch a
BLOB column, you (again) have to follow special rules. Once retrieved, the
data is in a DataTable column or DataReader stream--not in a form that Word
can recognize or open. This means you'll have to save the data back out to a
disk file somewhere and lose the properties associated with the file. This
means you'll also have to save the original word file properties in the
database too if you want to attempt to replicate them in the new file--I
expect this will be a challenge. Okay now you have to get word to open the
file and save it (or just read it). To get it back to the database the
process must be repeated.

It's for these and many other reasons that I don't recommend storing BLOBs
in the database. I store a path to the file in the database so I simply
retrieve the path and hand it to Word.

hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
I have managed to upload a byte array that represents the document to the
database. When I try to I get the byte array from the database and store it
in a .doc file that works too, but when I open gthe document it's filled
with small rectangles.
Any ideas?

/Henke
 
Could it be a Unicode issue?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
¤ Hi
¤ I'd like to stream a word document to a sql server database and then read it
¤ back to a file again.
¤ How can this be done?
¤

See if the following works for you:

HOW TO: Read and Write a File to and from a BLOB Column by Using ADO.NET and Visual Basic .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;316887


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top