Question How to retrieve .pdf file from varbinary(max) colunm

Zulu79

New member
Joined
Apr 26, 2013
Messages
1
Programming Experience
1-3
Here is my issue, how do I retrieve a .pdf from varbinary(max) colunm using VB.Net I was able to save to sql using:
Dim pdf As String
Dim pdfByteArray As Byte()
Dim lLenPdf As Integer = Len("C:\pdfFile.pdf")
Dim mypdf(100000)() As Byte
Dim numBytes As Long = pdfFile.Length
Dim data As Byte() = System.IO.File.ReadAllBytes("C:\pdfFile.pdf ")
myInitialBytes.Add(New Byte() {&H0, &H25})


StoredProc??.


Dim Local_Connection As New _
System.Data.SqlClient.SqlConnection?..



Local_Command.CommandText = "Insertpdf Tbl"
Local_Command.CommandType = CommandType.StoredProcedure
Local_Command.Connection = Local_Connection
Local_Command.Parameters.Clear()

Local_Command.CommandTimeout = 30

Local_Connection.Close()
 
You get a Byte array from a database the same way as you get any other data. You get the value from the database using a query and then call File.WriteAllBytes to write the data back out to a file. If the data was originally read using File.ReadAllBytes then you will faitfully recreate the original file.
 
Back
Top