views:

65

answers:

3

How to edit a Word Document (.docx) stored in a SQL Server Table?

Here is the tentative work flow:

  1. Read BLOB from SQL Table through Ideablade
  2. Write BLOB to disk as .docx
  3. Open .docx using Word
  4. User makes changes
  5. Save .docx using Word
  6. Read .docx into BLOB
  7. Write BLOB back to SQL Table through Ideablade

All sample code is welcomed?
I am sure there are a lot of people doing this already.

Any other ideas on how to simplify this process?

I am using VB.NET, .NET 3.5 SP1, WinForm and SQL Server 2008.

A: 

The method I've seen for this that I think works best is to build this as an add-on for MS Word itself. Examples include the Save to Sharepoint, Save to Moodle, and other similar add-ins.

Joel Coehoorn
+2  A: 

Well, as to the how, here is how to read a blob and write a blob to SQL. Although frankly, unless you have very good reasons such as an existing backup system, you would probably be best served storing the file to the file system and the path and metadata in the database. Either way, abstract it in your BLL, so you can change your mind down the road.

Serapth
+2  A: 

Retrieving and updating the BLOB from the db shouldn't be a problem, you'll find lots of sample code to do that on the net.

A simple approach to your problem would be to create a "temp" or "working" directory somewhere and monitor it with System.IO.FileSystemWatcher (sample code). When the user wants to edit a file, fetch it from the db and store it the directory. Whenever the user saves the file, you'll get a notification from your FileSystemWatcher, so you can save it to the database. Don't forget to empty the directory from time to time.

svens