|
-
Mar 30th, 2006, 02:53 PM
#1
Thread Starter
Hyperactive Member
get PDF from SQL and view it?
How can i get a PDF from a SQL table and view it in the Adobe control?
I found this code but i dont know how to pass the data from SQL into the control.
Code:
Me.AxPdf1.Visible = True
Me.AxPdf1.setCurrentPage(1)
Me.AxPdf1.LoadFile("C:\MyFile.pdf")
Me.AxPdf1.gotoFirstPage()
Me.AxPdf1.Enabled = True
Me.AxPdf1.Select()
Me.AxPdf1.Show()
-
Mar 30th, 2006, 04:23 PM
#2
Re: get PDF from SQL and view it?
Check out "How to read and write BLOB Data" at http://support.microsoft.com/default...b;en-us;308042
USing that to save the PDF localy .... then you can use your code there to point to the file & display it.
-tg
-
Mar 30th, 2006, 05:21 PM
#3
Thread Starter
Hyperactive Member
Re: get PDF from SQL and view it?
Your idea works... but it only pulls one record at a time.
Any idea how i can pull all the records from the table?
Code:
strSQL = "SELECT dbo.StoredDocument.Doc " _
& "FROM dbo.LetterQueue INNER JOIN " _
& "dbo.StoredDocument ON dbo.LetterQueue.DocID = dbo.StoredDocument.DocID " _
& "WHERE (dbo.LetterQueue.DatePrinted IS NULL)"
OpenDataSet(dsData, strSQL, "MyImages")
Dim x As String = dsData.Tables("MyImages").Rows.Count - 1
Dim i As Integer
For i = 0 To x
Dim myRow As DataRow
myRow = dsData.Tables("MyImages").Rows(i)
Dim MyData() As Byte
MyData = myRow("Doc")
Dim K As Long
K = UBound(MyData)
Dim fs As New FileStream _
("C:\MyNewPDF.PDF", FileMode.Append, _
FileAccess.Write)
fs.Write(MyData, 0, K)
fs.Close()
fs = Nothing
Next
Me.AxPdf1.Visible = True
Me.AxPdf1.setCurrentPage(1)
Me.AxPdf1.LoadFile("C:\MyNewPDF.PDF")
Me.AxPdf1.gotoFirstPage()
Me.AxPdf1.Enabled = True
Me.AxPdf1.Select()
Me.AxPdf1.Show()
-
Mar 30th, 2006, 05:26 PM
#4
Re: get PDF from SQL and view it?
That IS retrieving all the records. It's just creating a single PDF file and overwriting it each time through the loop. If you want to see all the files then you need to save the field contents from each record to a different file name.
Also, I think you need to declare your 'x' variable as Integer, not String.
-
Mar 30th, 2006, 06:15 PM
#5
Thread Starter
Hyperactive Member
Re: get PDF from SQL and view it?
is there a way to append each record to the same file?
if i have three records in the table i will have three pages in the PDF.
-----
what i'm trying to do.
i have a 'print queue' that is sql table. this table stores all the pdf files that need to be printed each day. at the end of the day a user will open this winform app and see if there are any files that need to be printed...
if there is a better way of doing this please let me know because i walked into this process late in the game.
Last edited by texas; Mar 30th, 2006 at 06:24 PM.
-
Mar 30th, 2006, 06:20 PM
#6
Re: get PDF from SQL and view it?
You'd either need to know the binary format of PDF files or else have some component that could do it for you. There's a link to a PDF component in my signature but I'm not sure if it can do what you're asking as I've never actually used it myself.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|