title: Save/open OLE object from .mdb in vb winform
body: <p>I am trying to add a feature to my vb winform program where a user can attach files (.doc, .docx, .jpg, .pdf) to a mdb file that holds other text data. The binary file and the file name are stored in the DB.  The file name with path is passed as variable 'fpath'. below is what I have thus far (It is now working, meaning it saves the file name and binary data). Now, how can the user open the saved file? And, if it is a .doc or PDF etc, how do I make the default associated program open it? . Can someone help me with the rest? </p>
  
  <p>Here is the code to store the OLE object:</p>
  
  <pre><code> Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)        Handles btnClear.Click
      'data connection
      Dim cn As New OleDb.OleDbConnection
      cn.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0; Data Source=" &amp; _
                             Application.StartupPath &amp; "\data.mdb"
      cn.Open()
  
      'file name without path
      Dim flName As String = filename.Text 
  
      'open file from the disk (file path is the path to the file to be opened)
      Using fileStream As FileStream = File.OpenRead(fpath)
          'create new MemoryStream object
          Dim memStream As New MemoryStream()
          memStream.SetLength(fileStream.Length)
          'read file to MemoryStream
          fileStream.Read(memStream.GetBuffer(), 0, CInt(Fix(fileStream.Length)))
          Dim strImage As String = "?"
  
          Dim arr As Byte()
          arr = memStream.GetBuffer
          Dim cmd As New OleDb.OleDbCommand
          cmd.Connection = cn
          cmd.CommandText = "INSERT INTO tblstudent(name, photo) VALUES( ?, ?)"
          cmd.Parameters.Add("@name", OleDbType.Char).Value = flName
          cmd.Parameters.Add("@photo", OleDb.OleDbType.Binary).Value = arr
  
          cmd.ExecuteNonQuery()
  
          MsgBox("Data save successfully!")
          cn.Close()
      End Using
  End Sub
  </code></pre>