1. Olan Knight
  2. PowerBuilder
  3. Tuesday, 15 June 2021 14:31 PM UTC

PB2019R3

With much help I was able to hardcode a DBPARM string to get a DNS-less connection to a PostgreSQL database.

// hard coded DBPARM
"ConnectString='Driver=PostgreSQL Unicode;Database=nttest;Server=10.51.78.544;Port=5444;UID=oknight;PWD=oknight;',DisableBind=1,UseServerSidePrepare=1,PBCatalogOwner='chadba',StripParmNames='Yes'"

To make it generic so the customers can specify their own database information, I put the data into the Registry:




The application reads the registry and constructs to DBPARM string, which is >>> IDENTICAL <<< to the hardcoded string. Here's the constructed string:

"ConnectString='Driver=PostgreSQL Unicode;Database=nttest;Server=10.51.78.544;Port=5444;UID=oknight;PWD=oknight;',DisableBind=1,UseServerSidePrepare=1,PBCatalogOwner='chadba',StripParmNames='Yes'" 


In debug mode, when the app is run from the IDE using the hardcoded string for sqlca.DBParms, it works.
If I use the constructed string, it prompts me for a DSN!
The strings are identical.
This behavior occurs in the compiled EXE, as well.

WHAT is going on and how can I get the constructed string to connect without prompting me for a DSN?





 

Accepted Answer
Olan Knight Accepted Answer Pending Moderation
  1. Monday, 15 August 2022 16:00 PM UTC
  2. PowerBuilder
  3. # Permalink

UPDATE:

This is the dynamically constructed string that finally worked as the DBPARM for a PG database:

connectstring='driver=postgresql unicode;database=dev_v5;server=10.99.99.99;port=5444;uid=oknight;pwd=DeepPurple01;',disablebind=0,useserversideprepare=1,pbcatalogowner='chadba',stripparmnames='yes'


It's "dynamic" because the following values start off as variables that get replaced at runtime in code:

ConnectString='Driver=<driver>;Database=<db>;Server=<ip>;Port=<port>;UID=<userid>;PWD=<password>;'

Comment
  1. Miguel Leeuwe
  2. Tuesday, 16 August 2022 05:17 AM UTC
Thanks for sharing Olan!
  1. Helpful
There are no comments made yet.
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Wednesday, 16 June 2021 07:06 AM UTC
  2. PowerBuilder
  3. # 1

Olan

Have you tried reading those values from local text file instead of from registry ?

Here things works fine when run in debug mode and from exe.  We store values in a text (ini) file.

 

Comment
  1. Sivaprakash BKR
  2. Thursday, 17 June 2021 05:10 AM UTC
Another thing that you could try is to store the password in plain text format and check it (in case password is encrypted).
  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Tuesday, 15 June 2021 20:43 PM UTC
  2. PowerBuilder
  3. # 2

I updated the complete connections string in the Registry, read it into the app, used it as the DBPARM, and tried to connect:


The good news is that I was NOT prompted for a DSN!  :)   

Here's the string that was used:

"ConnectString='Driver=PostgreSQL Unicode;Database=nttest;Server=10.50.68.244;Port=5444;UID=cabdevusr;PWD=cabdevusr;',DisableBind=1,UseServerSidePrepare=1,PBCatalogOwner='chadba',StripParmNames='Yes',ConnectOption='SQL_DRIVER_CONNECT, SQL_DRIVER_NOPROMPT'"

Comment
  1. John Fauss
  2. Tuesday, 15 June 2021 21:50 PM UTC
Perhaps try including SQL_OPT_TRACE_ON to enable the ODBC Driver Manager Trace? The trace output will be written to the file \SQL.LOG, according to documentation in PB Connection Reference. You can specify the file using the SQL_OPT_TRACEFILE option.
  1. Helpful
  1. Olan Knight
  2. Tuesday, 15 June 2021 21:55 PM UTC
Thanks, John. I'll try that tomorrow.



  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 15 June 2021 20:28 PM UTC
  2. PowerBuilder
  3. # 3

Try adding this to DBParm:

,ConnectOption='SQL_DRIVER_CONNECT, SQL_DRIVER_NOPROMPT'

 

Comment
  1. Olan Knight
  2. Tuesday, 15 June 2021 20:36 PM UTC
Will try it right now. Thank you!

  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.