1. Marcos Bolonha
  2. PowerBuilder
  3. Wednesday, 10 March 2021 16:03 PM UTC

Hi,

I have found a strange behavior of PB when I use a DataStore into a user function. If I run the projet directly from powerbuilder the function returns the info correctly, but if I run from .EXE it does not work as expected.

I prepared and attached a small project for showing the problem:

Function uf_employeecurrentdepartment
///////////////////////////
string LastDept
integer ret

DataStore ds_lastdept
ds_lastdept = CREATE DataStore
ds_lastdept.DataObject = 'dw_employeedepartmenthistory'
ds_lastdept.SetTransObject(SQLCA)
ret = ds_lastdept.Retrieve(ID)

if ret > 0 then
int li = 1
do while li <= ds_lastdept.rowcount()

// Find the employee's current dept
if IsNull(ds_lastdept.object.EndDate[li]) then
LastDept = ds_lastdept.object.department_name[li]
exit
end if

li += 1
loop
else
MessageBox('Error',string(ret)+' rows retrieved.')
end if

destroy ds_lastdept

return LastDept
////////////////////////

Environment:
PB 2019 R3 Runtime 19.2.0.2670
SQL Server 2016 Express Edition

 

Please, could someone help me understand where is my mistake.

Attachments (1)
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 10 March 2021 19:45 PM UTC
  2. PowerBuilder
  3. # 1

Hi, Marcos -

Could be missing runtime DLL's. The IDE has access and knows where to find all of the runtime DLL's. You have to ensure the compiled app has access to them. Are ALL of the 19.2.0.2670 runtime DLL's present in the same folder as the executable?

Regards, John

Comment
  1. John Fauss
  2. Wednesday, 10 March 2021 20:18 PM UTC
Also, is the PBD that contains the DataWindow Object available to the executable. Sometimes the checkmark in the project object to create a PBD from a single PBL is unchecked.
  1. Helpful
  1. Marcos Bolonha
  2. Wednesday, 10 March 2021 20:27 PM UTC
Chris,

I have copied the test.exe to runtime DLL folder and run it from there. The same problem!
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 10 March 2021 20:45 PM UTC
And PBD files?
  1. Helpful
There are no comments made yet.
Marcos Bolonha Accepted Answer Pending Moderation
  1. Wednesday, 10 March 2021 19:41 PM UTC
  2. PowerBuilder
  3. # 2
Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 10 March 2021 18:56 PM UTC
  2. PowerBuilder
  3. # 3

Hi Marcos;

   FWIW: I would add some more code to check that all commands are working OK. For example the "SetTransObject" method. If that fails, your "goose is cooked" so to speak.  ;-)

Regards ... Chris

Comment
  1. Marcos Bolonha
  2. Wednesday, 10 March 2021 21:18 PM UTC
Hi Chris and John Fauss



I have changed the project painter to create the PDB and now it is working fine.



Thanks for your attention!



Marcos
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 10 March 2021 21:35 PM UTC
Hi Marcos ... awesome news! :-)
  1. Helpful
  1. Benjamin Gaesslein
  2. Thursday, 11 March 2021 07:57 AM UTC
To clarify why this happens: If you don't generate PBDs for your pbls, Powerbuilder will compile all objects that are directly referenced in your code into the exe. Dataobjects are only set as a string though, so PB will not recognize that you're using them. AFAIR you can also create a .pbr file and add paths to all Datawindows to that but generating pbds is more convenient.
  1. Helpful
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.