Blob

  • Hi all,

     

    I would like to save a pdf file in the database. Can I know that how can I do it? What are the data type i should use and what are the commands needed?

    Appreciate your help.

     

  • Here is a snippet of VB.Net code that I am currently using to do just that...

    **********************************************

    Dim crReportDocument As New ReportDocument

    Dim streamReport As Stream

    Dim byteReport()

    As Byte

    'export to binary PDF

    streamReport = crReportDocument.ExportToStream(ExportFormatType.PortableDocFormat)

    'size the byte array

    ReDim byteReport(streamReport.Length - 1)

    'move to the beginning

    streamReport.Seek(0, SeekOrigin.Begin)

    'read to the end

    streamReport.Read(byteReport, 0, streamReport.Length)

    ********************************************

    In this example I am using CrystalReports to first generate the PDF as a Stream, then reading the stream into a Byte array.  If you already have the pdf created, you'll need to open it as a FileStream, and read it into the Byte array.

    If you're using a stored procedure to do the insert, set the value of the parameter representing the PDF equal to the byte array.  The parameter should be of SQL type "Image" (which is a blob).

    Hope this helps.


    keith

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply