VB.NET - Save and Retrieve word document in Sql Database

Asked By Ben Sebuabe on 27-Jun-14 12:54 PM
Good day, gurus of this well-known site. I am using vb.net 2013 Ultimate and SQL 2012 and can some show/link me how to save and retrieve a word document from SQL database?
Robbe Morris replied to Ben Sebuabe on 27-Jun-14 12:54 PM
Little bit embarrassed about some of these older articles like this one showing how to save an image to a sql server database table.  Hungarian notation, bad error handling, etc...

But, the jist of storing a Microsoft word document to a sql server database table is pretty much the same.  You read the word document in as a byte[] using the FileStream class.  Store the value in sql server either as an Image data type or more proper in this case, varbinary.  To write it to the browser when you pull it out of the database, you'd use Response.BinaryWrite(your byte array goes here) and set the Response.ContentType to the Microsoft Word value.  Something like application/doc I think.

This is C# code but you should be able to get what you need for your VB.NET