vb.net - 在 Adobe 阅读器工具中显示和查看 pdf 文件
问题描述
我使用代码在 adobe reader 工具中查看 pdf 文件,然后将它们存储在 sql server 数据库中,我想要的是一种在 datagridview 中双击文件名时显示这些存储文件的方法我使用此代码显示 pdf 文件:
Private Sub btnNewItem_Click(sender As Object, e As EventArgs) Handles btnNewItem.Click
txtItemNO.Text = GetmaxID()
btnSaveItem.Enabled = True
ofd.Filter = "pdf Files|*.pdf"
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
txtpdfPath.Text = ofd.FileName
AxAcroPDF1.src = txtpdfPath.Text
End If
End Sub
这段代码将它们保存在数据库中:
Private Sub btnSaveItem_Click(sender As Object, e As EventArgs) Handles btnSaveItem.Click
Try
cmd = New SqlCommand("insert into TBL_Attaches (AttachID, AttachName, AttachDate, Picture, CatID) values (@AttachID, @AttachName, @AttachDate, @Picture, @CatID)", con)
con.Open()
With cmd.Parameters
.AddWithValue("@AttachID", txtItemNO.Text)
.AddWithValue("@AttachName", txtItemName.Text)
.AddWithValue("@AttachDate", dtDateSave.Value)
Dim fs As New FileStream(ofd.FileName, FileMode.Open, FileAccess.Read)
Dim br As New BinaryReader(fs)
Dim Filepdf() As Byte = br.ReadBytes(br.BaseStream.Length)
.AddWithValue("@Picture", Filepdf)
.AddWithValue("@CatID", cmbItemCat.SelectedValue)
End With
cmd.ExecuteNonQuery()
MsgBox("Done!", MsgBoxStyle.Information, "Save")
dgsittings()
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End Sub
这是我用来在 datagridview 中显示文件名的代码:
adapter = New SqlDataAdapter("select TBL_Attaches.AttachID, TBL_Attaches.AttachName, TBL_Attaches.AttachDate, TBL_CatFailes.CatName from TBL_Attaches inner join TBL_CatFailes on TBL_Attaches.CatID = TBL_CatFailes.CatID", con)
Dim dtG As New DataTable
adapter.Fill(dtG)
dgAttached.DataSource = dtG
当我在datagridview中双击它的名称时,我只想显示pdf文件
解决方案
推荐阅读
- reactjs - React 无法在 IE11 和更旧的 Android 浏览器上运行
- android - setContentView 上的 NullPointerException
- html - 使用 flex 布局时 Chrome 滚动条损坏
- python - ModuleNotFoundError:没有名为“版本”的模块
- javascript - 如何在 nativescript javascript 中从远程 php 检索多个数据?
- node.js - 无法运行节点 server.js
- typeerror - solve_ivp 错误:“所需的步长小于数字之间的间距。”
- android - 对于在线安卓游戏,有哪些服务可以保证APK文件的完整性,防止作弊?
- compiler-errors - LEX - /usr/bin/i686-linux-gnu-ld: 找不到 -ll
- python - 如何根据另一个重新定位一个二进制图像?opencv-python