1. Tracy Lamb
  2. PowerBuilder
  3. Friday, 8 December 2023 00:42 AM UTC

Hi all,

I created a global datastore to retrieve SMTP email settings... when I retrieve the datastore, the retrieve function returns -1.  I know there is 1 record in the database, and the record shows up in the datawindow painter. 

Here's the code in the open event of my MDI frame:

gds_smtp_settings = CREATE datastore
gds_smtp_settings.dataobject = "d_smtp_settings"
gds_smtp_settings.SetTransObject( sqlca )
integer li_rc
li_rc = gds_smtp_settings.Retrieve()
messagebox("smtp settings rowcount", li_rc)

 

gds_smtp_settings is declared as a global variable... datastore gds_smtp_settings

Any rooky moves in the code/logic?  Using PB2022 R2, PFC2022.

TIA,

Tracy

 

 

Accepted Answer
Tracy Lamb Accepted Answer Pending Moderation
  1. Friday, 8 December 2023 13:39 PM UTC
  2. PowerBuilder
  3. # Permalink

Thank you all for your responses.  Turns out to be operator error... :(  I had to move the code from the open event to the custom event ue_logon (which is triggered by the open event) to ensure the user is successfully logged on to the database prior to trying to retrieve data.  In the open event, there is no valid sqlca object yet. 

So sorry to have wasted your time (and mine).

~~~Tracy

Comment
  1. Chris Pollach @Appeon
  2. Friday, 8 December 2023 14:57 PM UTC
I am super glad Tracy that you found the problem (and .. it was not PB's - LOL)! ;-)
  1. Helpful
  1. Tracy Lamb
  2. Friday, 8 December 2023 15:46 PM UTC
Lol! Extremely rare that it's PB's fault!

  1. Helpful 1
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 8 December 2023 01:11 AM UTC
  2. PowerBuilder
  3. # 1

Hi Tracy;

  I would check the RC on the SetTransObject() to if it worked ok first. Then the RC for the Retrieve() should be a "Long" data type.

  Also, make sure that your PBLs are marked to generate PBDs as well. Otherwise, your DWOs will not be there when the App is deployed.  HTH

Regards ... Chris 

Comment
  1. Chris Pollach @Appeon
  2. Friday, 8 December 2023 01:29 AM UTC
FWIW: Then either the DWO is missing (ie: no PBD) or your DBMS connect on SQLCA is not working.
  1. Helpful
  1. John Fauss
  2. Friday, 8 December 2023 02:47 AM UTC
@Tracy - You can also check the return value of the SQLCA.DBHandle() function. If the connection to the database is valid, the Long return value will be > 0.
  1. Helpful
  1. Sivaprakash BKR
  2. Friday, 8 December 2023 07:11 AM UTC
Can you check

Connect using SQLCA ;

has been executed earlier to this datastore retrieve.
  1. Helpful 1
There are no comments made yet.
John Raghanti Accepted Answer Pending Moderation
  1. Friday, 8 December 2023 12:22 PM UTC
  2. PowerBuilder
  3. # 2

Hi. You didn't mention what database you're using, but if you're using SQL Server, you can use the Profiler to see if the SQL is hitting the database and if it's constructed properly. I'm sure other databases have something similar.

Comment
There are no comments made yet.
Arnd Schmidt Accepted Answer Pending Moderation
  1. Friday, 8 December 2023 13:20 PM UTC
  2. PowerBuilder
  3. # 3

IF you are using the PFC :

gds_smtp_settings = CREATE n_ds

There is a dberror event coded for you.

hth

Arnd

Comment
  1. Tracy Lamb
  2. Friday, 8 December 2023 14:10 PM UTC
I forgot there's a pfc n_ds I could use also. Thanks for the reminder.
  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.