Hi Scott,
Sorry for the delay in getting back to you.
Here are some code snippet for doing the following:
1. Save a Doc file into a SQL Table column.
//Open the file as stream
Stream Sample = new MemoryStream();
Sample = new FileStream(Server.MapPath("sample.doc"), FileMode.Open, FileAccess.ReadWrite);
//store the bytes in a array
byte[] aDocByteArray = new Byte[Sample.Length];
Sample.Read(aDocByteArray, 0, System.Convert.ToInt32(Sample.Length));
Sample.Seek(0, SeekOrigin.Begin);
//Save it to database as binary
SqlParameter myParameter = new SqlParameter("@doc", SqlDbType.VarBinary, aDocByteArray.Length);
myParameter.Value = aPdfDocByteArray;
mCommand.Parameters.Add(myParameter);
mCommand.ExecuteNonQuery();
2. Retrieve a document from a SQL table column into a DocIO document object.
//get the doc from the database
byte[] DocByteArray = (byte[])myCommand.ExecuteScalar();
//Create a FileStream
FileStream fs = new FileStream("Sample.doc", FileMode.Create);
fs.Write(DocByteArray, 0, System.Convert.ToInt32(DocByteArray.Length));
fs.Seek(0, SeekOrigin.Begin);
3. Ability to update predefined Book Marks within the document with data supplied via program variables.
//open the document from database
WordDocument ldoc = new WordDocument(OpenDatabase(Conn));
//Add some bookmarks
AddBookmarks(ldoc);
4. Send the document to the user’s browser and have it open directly in MS Word application.
// Creating a memory Stream.
MemoryStream ms = new MemoryStream();
// Save the pdf document to the Stream.
ldoc.Save(ms,FormatType.Doc);
Response.OutputStream.Write(formSample.GetBuffer(), 0, formSample.GetBuffer().Length);
Currently we do not have support for opening a word document as stream.Hence you have to save the document as file when you retrieve the document from database[in step 2].I will consult with development team regarding this feature and send you an update as soon as I hear back.
Here is a sample for your reference:
SaveToDatabase.zip
Please let me know if you have any other queries.
Regards,
Dhivya.