如何使用vb检索和查看存储在访问中的pdf文件 [英] how to retrieve and view pdf file stored in access using vb
本文介绍了如何使用vb检索和查看存储在访问中的pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的编码,但它没有打开文件。请帮帮我
this is my coding but its not opening the file. please help me
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\ATECH1\Documents\pdf.accdb")
Dim DestFilePath As String = "C:\Documents\pdf.accdb "
Dim RetVal As Long
Dim FieldLen As String
con.Open()
Dim cmd As New OleDbCommand("select filename from files where filename= '" & TextBox1.Text & "' ", con)
' With cmd.Parameters
'.AddWithValue("@filename", TextBox1.Text)
Try
Dim AccessDataReader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
AccessDataReader.Read()
FieldLen = AccessDataReader.Item("filename").ToString
Dim BlobByteArray(FieldLen - 0) As Byte
Dim startIndex As Integer = 0
RetVal = AccessDataReader.GetBytes(0, startIndex, BlobByteArray, 0, BlobByteArray.Length)
Dim FileStreamObject As New System.IO.FileStream(DestFilePath, IO.FileMode.Open, IO.FileAccess.Write)
FileStreamObject.Write(BlobByteArray, 0, BlobByteArray.Length)
FileStreamObject.Close()
AccessDataReader.Close()
con.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
推荐答案
错误/异常是什么以及它在哪里?
Whats the error/exception and where it is ?
这篇关于如何使用vb检索和查看存储在访问中的pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文