从SQL数据库中检索PDF文件 [英] Retrieve PDF file from SQL database
本文介绍了从SQL数据库中检索PDF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请使用代码将pdf文件上传到数据库中,它完美无缺,我需要有关如何将pdf文件检索到测试盒的帮助。
Dim fInfo As New FileInfo(txtcv.Text)
Dim numBytes As Long = fInfo.Length
Dim fStream As New FileStream(txtcv.Text, FileMode.Open,FileAccess.Read)
Dim br As New BinaryReader(fStream)
Dim data As Byte()= br.ReadBytes(CInt(numBytes))
br.Close()
fStream.Close()
con.Open()
cmd.Parameters.AddWithValue(@ CV,data)
我的尝试:
如果是sdr.HasRows那么
当sdr.Read()
如果sdr(CV)IsNot System.DBNull.Value则
Dim data As Byte()= DirectCast(sdr(CV),Byte( ))
Dim ms As New MemoryStream(data)
Me.data.Text = IO.File.ReadAllBytes(data)
结束如果
结束时
sdr.Close()
结束如果
con.Close()
但它不起作用
解决方案
对你要问的东西进行疯狂刺杀,这可能就是你在寻找的东西for:
此Google搜索:在winform app中显示pdf [ ^ ]
发现:在winforms中查看PDF [ ^ ]
这个谷歌搜索:memorystream to pdf - Google搜索 [ ^ ]
发现这个: 将字节数组转换为c#中的pdf [< a href =https://www.codeproject.com/Questions/203627/Convert-a-byte-array-to-pdf-in-ctarget =_ blanktitle =New Window> ^
Please I use the code to upload pdf file into the database, it works perfect, I need help on how to retrieve the pdf file into a testbox.
Dim fInfo As New FileInfo(txtcv.Text) Dim numBytes As Long = fInfo.Length Dim fStream As New FileStream(txtcv.Text, FileMode.Open, FileAccess.Read) Dim br As New BinaryReader(fStream) Dim data As Byte() = br.ReadBytes(CInt(numBytes)) br.Close() fStream.Close() con.Open() cmd.Parameters.AddWithValue("@CV", data)
What I have tried:
If sdr.HasRows Then While sdr.Read() If sdr("CV") IsNot System.DBNull.Value Then Dim data As Byte() = DirectCast(sdr("CV"), Byte()) Dim ms As New MemoryStream(data) Me.data.Text = IO.File.ReadAllBytes(data) End If End While sdr.Close() End If con.Close()
but its not working
解决方案
Taking a wild stab at what you are asking, this may be what you are looking for:
This Google Search: display pdf in winform app[^]
Found this: Viewing PDF in winforms[^]
And this Google Search: memorystream to pdf - Google Search[^]
Found this: Convert a byte array to pdf in c#[^]
这篇关于从SQL数据库中检索PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文