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.
joaquiniglesiasAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
joaquiniglesiasAuthor Commented:
Its working now, thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.