|Please I am using VB.net 2019 and Sql 2016 and I have the below codes which inserts the pdf into the database successfully. But retrieving it becomes a problem for me and that is not the case for an image. I want to convert and retrieve this line of code into pdf "Me.Pdf1.Image=Image.fromStream(ms)" which gives an exception because it is not an image but pdf in the database. Please help me. Thank
txtPdfPath.Text = OpenFileDialog1.FileName
Dim ms1 As New MemoryStream
SqlQuery = "Insert into BPA1 (Pdf1)Values(@Pdf1)"
com.CommandText = SqlQuery
com.CommandType = CommandType.Text
Dim strQuery As String = "Select df1 from BPA1"
comFile = New SqlCommand(strQuery, SQLCon1)
daFile = New SqlDataAdapter(comFile)
If taFile.Rows(0).Item("Pic1") IsNot DBNull.Value Then
Dim img() As Byte
img = taFile.Rows(0).Item("Pdf1")
Dim ms As New MemoryStream(img)
If img.Length <> "0" Then
Me.Pic1.Image = Image.FromStream(ms)