我尝试过此代码,该文件打开但为空。我的Pdf数据已保存为Long二进制数据,可以访问。
Private Sub Button2_Click(sender As Object,e As EventArgs) Handles Button2.Click
Dim cmd As New OleDbCommand("SELECT Pdf FROM tblBinary WHERE Identity = 'n'",cn)
Dim dt1 As New DataTable
'Dim fileData As Byte() = DirectCast(cmd.ExecuteScalar(),Byte())
Using reader As OleDbdataReader = cmd.ExecuteReader()
While reader.Read()
Dim fileData As Byte() = DirectCast(reader("Pdf"),Byte())
Using fs As New FileStream("C:\Users\nelsn\Desktop\Testing1.doc",FileMode.Create,Fileaccess.Write)
fs.Write(fileData,fileData.Length)
fs.Flush()
fs.Close()
End Using
System.Diagnostics.Process.Start("C:\Users\nelsn\Desktop\Testing1.doc")
End While
End Using
End Sub