public static void StoreToDatabase(Document doc, OleDbConnection mConnection)
{
// Save the document to a MemoryStream object.
MemoryStream stream = new MemoryStream();
doc.Save(stream, SaveFormat.Doc);
// Get the filename from the document.
string fileName = Path.GetFileName(doc.OriginalFileName);
// Create the SQL command.
string commandString = "INSERT INTO Documents (FileName, FileContent) VALUES('" + fileName + "', @Doc)";
OleDbCommand command = new OleDbCommand(commandString, mConnection);
// Add the @Doc parameter.
command.Parameters.AddWithValue("Doc", stream.ToArray());
// Write the document to the database.
command.ExecuteNonQuery();
}
// ExEnd:StoreToDatabase