Real Software Forums
http://forums.realsoftware.com/

Display PDF's files from database
http://forums.realsoftware.com/viewtopic.php?f=6&t=47565
Page 2 of 2

Author:  gwilmer [ Mon Apr 15, 2013 3:51 pm ]
Post subject:  Re: Display PDF's files from database

posting.php?mode=reply&f=6&t=47565#
I have been struggling with this as well. Here is the solution.
a) to upload a pdf, I convert the pdf to binary and store the string in the db
b) to retrieve and display you need to take several steps.
1) in the 2011 4.3 RS download, go to the Examples folder
there is a folder "MemoryBlock" (for some reason it is not there in later versions)
copy the MemBlockString class into you project
2) the code
dim bs as BinaryStream
dim f as FolderItem
dim mb As new MemBlockString

f=GetFolderItem("temp")

bs= BinaryStream.Create(f, true)

mb.appendString PictureHex
bs.Write(mb.getString)
:D f.Launch

PictureHex is the string from you SQL query

Author:  dhernandez [ Mon Apr 15, 2013 5:10 pm ]
Post subject:  Re: Display PDF's files from database

It will have it replaced by another class? Then install the RS 2011, but that means I have to uninstall the version I have and is the RS 2012 Enterprise. :(

Author:  timhare [ Mon Apr 15, 2013 5:58 pm ]
Post subject:  Re: Display PDF's files from database

You don't need a memoryblock at all. Just write the string directly.

dim bs as BinaryStream
dim f as FolderItem

f=GetFolderItem("temp")

bs= BinaryStream.Create(f, true)

bs.Write(PictureHex)
f.Launch

Author:  dhernandez [ Tue Apr 16, 2013 8:13 am ]
Post subject:  Re: Display PDF's files from database

Ok. I'm working on it, thank you for your contributions ...

Author:  dhernandez [ Tue Apr 16, 2013 10:07 am ]
Post subject:  Re: Display PDF's files from database

I'm working on downloading the PDF file stored in Oracle Database. I have this code to open the form window.

If ListBox1.ListIndex<>-1 Then
DIM SQLDATA As String ="SELECT DOCUMENTOS FROM CAL_DOCUMENTOS2 WHERE NAME='"+Trim(ListBox1.Cell(ListBox1.ListIndex,0))+"'"
DIM CONECT As RecordSet =XE.SQLSelect(SQLDATA)
DIM BS As BinaryStream
DIM F As FolderItem

F=GetFolderItem("Ejemplo")
BS=BinaryStream.Create(F, True)
BS.Write CONECT.Field("DOCUMENTOS").NativeValue
BS.Close
Else
MsgBox "Select An Option"
End If

The folder "Ejemplo" in Spanish, is where the file should be stored. I think not. There I was doing something wrong?

Author:  dhernandez [ Tue Apr 16, 2013 10:52 am ]
Post subject:  Re: Display PDF's files from database

Corrected file path, was well, but when viewing the file has 0 bytes.

If ListBox1.ListIndex<>-1 Then
DIM SQLDATA As String ="SELECT DOCUMENTOS FROM CAL_DOCUMENTOS2 WHERE NAME='"+Trim(ListBox1.Cell(ListBox1.ListIndex,0))+"'"
DIM CONECT As RecordSet =XE.SQLSelect(SQLDATA)
DIM BS As BinaryStream
DIM F As FolderItem

F=GetFolderItem("C:\Users\SANTIAGO\Desktop\Download")
BS=BinaryStream.Create(F, True)
BS.Write CONECT.Field("DOCUMENTOS").NativeValue
BS.Close
Else
MsgBox "Select An Option"
End If

Author:  timhare [ Tue Apr 16, 2013 1:01 pm ]
Post subject:  Re: Display PDF's files from database

Try StringValue instead of NativeValue.

Author:  dhernandez [ Tue Apr 16, 2013 1:44 pm ]
Post subject:  Re: Display PDF's files from database

Thanks for your comment, change the options, but now it does not save any files in the specified path

Page 2 of 2 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/