I made a similar post but I need help again... I'm trying to save a word document into an access database (to the OLE Object field) and then retrieve it and open it again.

I used a code I got for saving images to a database to save the Word document into the database:

VB Code:
  1. Dim da As New OleDbDataAdapter("SELECT * FROM Attachments", cnn)
  2.         Dim command As OleDbCommandBuilder = New OleDbCommandBuilder(da)
  3.         Dim ds As New DataSet
  4.         Dim myRow As DataRow
  5.  
  6.         da.MissingSchemaAction = MissingSchemaAction.AddWithKey
  7.  
  8.         Dim fs As New FileStream("C:\Document.doc", FileMode.OpenOrCreate, FileAccess.Read)
  9.         Dim MyData(fs.Length) As Byte
  10.  
  11.         fs.Read(MyData, 0, fs.Length)
  12.         fs.Close()
  13.  
  14.         cnn.Open()
  15.  
  16.         da.Fill(ds, "Attachments")
  17.  
  18.         'add a new row to the dataTable
  19.  
  20.         myRow = ds.Tables("Attachments").NewRow()
  21.         myRow("FileName") = "Document"
  22.         myRow("PolicyNumber") = "20-001"
  23.         myRow("File") = MyData
  24.  
  25.         'update the table and DataSet
  26.  
  27.         ds.Tables("Attachments").Rows.Add(myRow)
  28.         da.Update(ds, "Attachments")
  29.  
  30.         fs = Nothing
  31.         command = Nothing
  32.         ds = Nothing
  33.         da = Nothing
  34.         cnn.Close()
  35.         cnn = Nothing

and then the code for retrieving and opening the file (thanks for the code mendhak):

VB Code:
  1. Dim byteArrayOfData As Byte
  2.         Dim bw As BinaryWriter
  3.         Dim fs As FileStream = New FileStream("C:\Temp\Document.doc", FileMode.OpenOrCreate, FileAccess.Write)
  4.  
  5.         Dim cmdAtt As New OleDb.OleDbCommand
  6.         Dim daAtt As New OleDb.OleDbDataAdapter
  7.         Dim dsAtt As New DataSet
  8.  
  9.         cmdAtt = cnn.CreateCommand
  10.         cmdAtt.CommandText = "SELECT * FROM Attachments"
  11.         daAtt.SelectCommand = cmdAtt
  12.         Dim cb As OleDbCommandBuilder = _
  13.             New OleDbCommandBuilder(daAtt)
  14.         daAtt.Fill(dsAtt, "Attachments")
  15.  
  16.         byteArrayOfData = dsAtt.Tables("Attachments").Rows(0).Item("File")
  17.  
  18.         bw = New BinaryWriter(fs)
  19.         bw.Write(byteArrayOfData)
  20.         bw.Flush()
  21.         bw.Close()
  22.         fs.Close()
  23.  
  24.         'Once the file is written,
  25.  
  26.         System.Diagnostics.ProcessStart("C:\Temp\Document.doc")

I must be doing something wrong cuz the document that it created doesnt have anything.