Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1624
  • Last Modified:

Ole images powerbuilder 10

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.
0
joaquiniglesias
Asked:
joaquiniglesias
1 Solution
 
diasroshanCommented:
Hi,

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)

 Else
 
   // 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"
   else
    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
   FileDelete("C:\_APPS\ERPP\emp_pic.bmp")
  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
   ELSE
    li_loops = (ll_file_len / 32765) + 1
   END IF

  ELSE
   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
  NEXT

  // Closes file
  FileClose(li_fileNum)

  // 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

Cheers,
Rosh
0
 
joaquiniglesiasAuthor Commented:
Its working now, thanks.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now