Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Sep 20, 2017 4:21 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Display PDF's files from database
PostPosted: Mon Apr 15, 2013 3:51 pm 
Offline

Joined: Wed Jun 15, 2011 12:16 am
Posts: 3
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Display PDF's files from database
PostPosted: Mon Apr 15, 2013 5:10 pm 
Offline

Joined: Tue Apr 09, 2013 3:09 pm
Posts: 24
Location: Reynosa, Tamps. Mexico
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. :(


Top
 Profile  
Reply with quote  
 Post subject: Re: Display PDF's files from database
PostPosted: Mon Apr 15, 2013 5:58 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Display PDF's files from database
PostPosted: Tue Apr 16, 2013 8:13 am 
Offline

Joined: Tue Apr 09, 2013 3:09 pm
Posts: 24
Location: Reynosa, Tamps. Mexico
Ok. I'm working on it, thank you for your contributions ...


Top
 Profile  
Reply with quote  
 Post subject: Re: Display PDF's files from database
PostPosted: Tue Apr 16, 2013 10:07 am 
Offline

Joined: Tue Apr 09, 2013 3:09 pm
Posts: 24
Location: Reynosa, Tamps. Mexico
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: Display PDF's files from database
PostPosted: Tue Apr 16, 2013 10:52 am 
Offline

Joined: Tue Apr 09, 2013 3:09 pm
Posts: 24
Location: Reynosa, Tamps. Mexico
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Display PDF's files from database
PostPosted: Tue Apr 16, 2013 1:01 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Try StringValue instead of NativeValue.


Top
 Profile  
Reply with quote  
 Post subject: Re: Display PDF's files from database
PostPosted: Tue Apr 16, 2013 1:44 pm 
Offline

Joined: Tue Apr 09, 2013 3:09 pm
Posts: 24
Location: Reynosa, Tamps. Mexico
Thanks for your comment, change the options, but now it does not save any files in the specified path


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group