1. James Medick
  2. PowerBuilder
  3. Sunday, 21 June 2020 16:33 PM UTC

I have an Oledatabase Blob object on a datawindow that works fine.  I can store and retrieve to the database.  I would like to add a function to select an existing document and store it as a blob in the table.  I'm using the GetOpenFileName function (lastest version of PB), which selects the file and stores it in a Blob variable.  I then take the variable and update the table through embeded SQL.  This works, but when using the OleDatabase Blob object (clicked event), it retrieves a blank document.

Updating any blob in the table directly causes the PB object not to work.  I suspect either that PB has some additional controls its using or I am updating the blob column in error.  The code looks like:

if GetFileOpenName ("Select File", ls_fullname, ls_filename) < 1 Then
return
End If

li_fileid = FileOpen (ls_fullname, StreamMode!)
FileReadEX (li_fileid, lb_policy)
FileClose (li_fileid)

ls_id = dw_detail.GetItemString(1, "idpolicies")
Update policy_blob Set policy_blob = :lb_policy
Where idpolicies = :ls_id
Using SQLCA;
If SQLCA.SQLCODE = 0 Then
Commit Using SQLCA;
Else
RollBack Using SQLCA;
MessageBox("System Failure", "Failure to update the blob object")
End If

This code runs without error but the PB data window object will not display it.  it will only display what it wrote itself.

James

James Medick Accepted Answer Pending Moderation
  1. Monday, 22 June 2020 19:54 PM UTC
  2. PowerBuilder
  3. # 1

Is the only way to use the OleDatabase Object is to always start with a blank document, then fill in some data (copy, paste) and save it.  Once saved it can be retrieved and modified.

If there is an existing document, then the choice would be to use the FileOpen, FileRead approach?

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 22 June 2020 15:18 PM UTC
  2. PowerBuilder
  3. # 2

Hi James;

   Yes, the OLE data stream would contain not only the binary datum for the respective content (ie: image, Excel, PDF, etc) but also, OLE binary directives for handling the OLE conversation with the respective OLE Server that renders the basic datum.

   When you read and update the Table Blob column directly, you then would be missing the OLE "directive" data that wrappers the base datum. Thus when the OLE conversation is activated, nothing would appear as there is no directive data. However, I suspect that if you reconstituted the Blob data into it's native file format (ie: PDF, XLSX, etc) and then issued a RUN() command on those files, the corresponding application would render the data OK.

HTH

Regards ... Chris

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.