Using SQL-Server as a document store

  • Hi

    I've done this in Oracle 9 (using InProcServer) but need to port the database to SQL-Server.

    I need to be able to import a document (or any file type) to a blob column in the database. The interface is VB6 i.e the user chooses a file via the common dialog and the file is imported into the database.

    I will then need to be to re-create the file (document etc) on a users machine and open that document using the relevant tool, such as Word. The requirement is basically a document store, using the database to store the files.

    How do you do this in SQL-Server?

    Thanks for any help.

     

     

     

  • Assuming that the VB6 program is using ADO, the program will read the file into a byte-array (using stream object is usually the easiest way), then update the recordset column with the byte-array variable.  The blob column on the table will be a varbinary field, and you will also want to have a varchar column with the file name. 

    To recreate the document just reverse the steps: retrieve the data in a recordset, copy it to a byte-array, and write the byte-array to a stream object, using the filename.

    Hope this helps



    Mark

  • You pointed me in exactly the right direction. Saved me hours!

    Cheers

    Mark.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply