Ole images powerbuilder 10

Posted on 2006-03-26
Last Modified: 2013-12-26
Dear Experts ;

I need help related to ole objects in powerbuilder, i want to load an image from my hard drive into an ole control ( from an open dialog box ) and then save that image in the database. I was able to make the code for saving and it works, also i was able to make the code for showing the image with SelectBlob from the database, BUT my PROBLEM is that i cannot load the image in the ole OBJECT from my hard drive, so i only save and show empty images in the ole.
I also try to load the image from the hard disk in a picture control, it worked but when a save , it saves an empty image.
Please help with the code for loading an image to ole object from hardrive.
Question by:joaquiniglesias
    LVL 18

    Accepted Solution


    this is a very nice sample code posted by one of our experts for a similar post...

    // Retrieves picture from database
     selectblob emp_pic
      into :b_pic
      from erpp_employee_info
      where last_name = :is_lname
      and first_name = :is_fname
      and sect_assign = :is_section;

     //As long as there was a picture
     if (SQLCA.SQLCode = 0 AND NOT isNull(b_pic)) then

      // Get the file length
      ll_file_len = Len(b_pic)

       // Determines what blank picture file to use
       if (FileExists("C:\_APPS\ERPP\nopic.bmp")) then
        this.dw_1.object.p_emp.filename = "C:\_APPS\ERPP\nopic.bmp"
        this.dw_1.object.p_emp.filename = "nopic.bmp"
       end if

       return lb_rc

      end if

      // Remove old picture file
      if (FileExists("C:\_APPS\ERPP\emp_pic.bmp")) then
      end if

      // Opens picture file
      li_fileNum = FileOpen("C:\_APPS\ERPP\emp_pic.bmp", StreamMode!,
      & Write!, LockReadWrite!)

      // Determine how many times to call FileWrite
      IF (ll_file_len > 32765) THEN

       // Determines how many loops we need
       IF (Mod(ll_file_len, 32765) = 0) THEN
        li_loops = ll_file_len / 32765
        li_loops = (ll_file_len / 32765) + 1
       END IF

       li_loops = 1
      END IF

      // Initializes
      ll_tot_bytes = 1

      // Writes blob to file
      FOR i = 1 to li_loops
       b_temp = BlobMid(b_pic, ll_tot_bytes, 32765)
       ll_bytes = FileWrite(li_fileNum, b_temp)
       ll_tot_bytes += ll_bytes

      // Closes file

      // Sets picture file to DW
      this.dw_1.object.p_emp.filename = "C:\_APPS\ERPP\emp_pic.bmp"

    The above code saves the database blob column to a temporary file on disk,
    then assign it to a empty bitmap control on the dw


    Author Comment

    Its working now, thanks.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
    Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now